Is white space allowed betwee mime header field-name and ':' separator

拈花ヽ惹草 提交于 2019-12-19 18:29:50

问题


Within a mime header, is white space allowed between the header field-name and ':' separator? For example, are:

Content-Type: <value>

and

Content-Type  : <value>

equivalent?

Also, can you please provide a pointer to the mime standard where this is described? I checked a few but did not find it.

Thanks


回答1:


It isn't entirely clear whether it is or is not allowed, by the standard. However, implementations vary in how they handle whitespace between header field names and the colon. I would highly recommend avoiding whitespace there if you can.

The RFC for reference. This somewhat old article discusses the issue for HTTP headers, a similar standard.




回答2:


Depends on what you mean by 'allowed'. RFCs 2822 (which obsoleted the 1982 RFC822) and 5322 (which obsoleted 2822) specifically forbid the insertion of WS between the field name and the colon (these are not 'MIME' standards, BTW). Note that : is not a token, and is only referenced as part of a field name, for example:

from = "From:" mailbox-list CRLF

However, the ancient RFC822 did allow space here, and the newer RFCs state that the obsolete syntax "MUST be accepted and parsed by a conformant receiver". The obsolete From: header definition, for example, was

obs-from = "From" *WSP ":" mailbox-list CRLF

Section 4 covers the obsolete syntax. I don't actually allow obsolete syntax in my own receiver, and I've never had a problem.




回答3:


If the question is about the HTTP then the answer is "no, not allowed". See http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p1-messaging-21.html#rfc.section.3.2



来源:https://stackoverflow.com/questions/13295845/is-white-space-allowed-betwee-mime-header-field-name-and-separator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!