multipart/form-data中的“-"是什么? [英] What is the '-' in multipart/form-data?

查看:128
本文介绍了multipart/form-data中的“-"是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一个有关多部分/表单数据的问题.我找到了multipart帖子的http标头和Content-Type:multipart/form-data; boundary = -----...-- boundaryNumber.我想问一下,boundaryNumber和'='之间有多少个'-'?

I want to ask a question about the multipart/form data. I find the http header of multipart post and the Content-Type: multipart/form-data; boundary=-----...---boundaryNumber. I want to ask, how many of '-' between the boundaryNumber and '='?

推荐答案

不是唯一的-是必需的.您可以有任意数量.对于我来说,为什么用户代理往往会增加这么多,这实际上是一个谜.这可能是传统的,因为在过去,当人们仍然定期查看实际的协议流量时,它提供了很好的视觉隔离.如今,它已经毫无意义.

Not a single - is mandatory. You can have any number of them. It is actually a mystery to me why user-agents tend to add so many. It is probably traditional because in the old days, when people still regularly looked at the actual protocol traffic, it provided some nice visual separation. Nowadays it is pointless.

但是请注意,当您使用流中的边界时,它必须以两个连字符(--)为前缀.这是协议的一部分.当然,大多数用户代理在其边界中使用大量的连字符这一事实使得通过示例很难看出这一点.

Note however, that when you use the boundary in the stream, it must be prefixed by two hyphens (--). That’s part of the protocol. Of course, the fact that most user-agents use lots of hyphens in their boundary makes this very hard to see by example.

此外, last 边界(标记消息的结尾)以为前缀,并以两个连字符(--)后缀.

Furthermore, the last boundary (which marks the end of the message) is prefixed and suffixed by two hyphens (--).

因此,总而言之,您可以将边界称为OMGWTFPLZDIEKTHX,然后您的点击量可能如下所示:

So in summary, you could call your boundary OMGWTFPLZDIEKTHX, and then your traffic could look like this:

Content-Type: multipart/form-data; boundary=OMGWTFPLZDIEKTHX

--OMGWTFPLZDIEKTHX
Content-Type: text/plain

First part (plain text).
--OMGWTFPLZDIEKTHX
Content-Type: text/html

<html>Second part (HTML).</html>
--OMGWTFPLZDIEKTHX--

这篇关于multipart/form-data中的“-"是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆