HTTP header 中的空格被认为是什么

What is considered as whitespace in HTTP header

我刚刚阅读了 HTTP 标准(提出的标准 更准确)第 1 部分,并且对第 3 部分中他们认为是“空白”的内容感到困惑,其次是最后一段: https://www.rfc-editor.org/rfc/rfc7230#section-3

由于 returns (CRLFs) 终止 HTTP header,可能隐含的唯一空格是 0x20 'Space' 字符。维基百科列出了另一种空白 ASCII 符号,例如 'Non-breaking space' 0xA0,所以我仍然不理解这个(“空白”)概念。

请帮我弄清楚它在这个标准范围内的真正含义。

  1. 另见 https://www.rfc-editor.org/rfc/rfc7230#section-3.2.3

  2. HTAB 也是空白。

  3. 在第 3 节的上下文中,“发送方不得在 start-line 和第一个 header 字段之间发送空格。”也指额外的换行符。

您链接到的 RFC 7230 在 header:

中准确定义了它认为是白色的space
HTTP-message   = start-line
                 *( header-field CRLF )
                 CRLF
                 [ message-body ]

header-field   = field-name ":" OWS field-value OWS

field-name     = token
field-value    = *( field-content / obs-fold )
field-content  = field-vchar [ 1*( SP / HTAB ) field-vchar ]
field-vchar    = VCHAR / obs-text

obs-fold       = CRLF 1*( SP / HTAB )
               ; obsolete line folding
               ; see Section 3.2.4

obs-text       = %x80-FF

OWS            = *( SP / HTAB )
               ; optional whitespace

如您所见,SP(space)和HTAB(水平制表符)是唯一定义的白色space字符。它们在 RFC 5234 Appendix B.1 中定义,RFC 7230 链接到:

HTAB           =  %x09
               ; horizontal tab

SP             =  %x20