我正在尝试在我的服务器中实现 HTTP,但无法找到有关如何处理多个尾部 header 字段(使用分块编码)的任何信息。
标准 ( https://www.rfc-editor.org/rfc/rfc2616#section-14.40 ) 指出: “Trailer 通用字段值表示给定的头字段集出现在使用分块传输编码编码的消息的尾部。”
但是没有说明如何在此 Trailer
header 中指定多个 header 。
例如,如果请求或响应有两个尾部 header ,Example1
和 Example2
,您将如何构造 Trailer
header ?
像这样:Trailer: Example1 Example2
或 Trailer: Example1,Example2
还是什么?
最佳答案
来自 RFC 2616:
14.40 Trailer Trailer = "Trailer" ":" 1#field-name
2.1 Augmented BNF #rule A construct "#" is defined, similar to "*", for defining lists of elements. The full form is "<n>#<m>element" indicating at least <n> and at most <m> elements, each separated by one or more commas (",") and OPTIONAL linear white space (LWS).
换句话说,你应该写:
预告片:示例 1、示例 2
请注意,RFC 2616 已被以下各项废弃:
- RFC 7230: Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing
- RFC 7231: Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content
- RFC 7232: Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests
- RFC 7233: Hypertext Transfer Protocol (HTTP/1.1): Range Requests
- RFC 7234: Hypertext Transfer Protocol (HTTP/1.1): Caching
- RFC 7235: Hypertext Transfer Protocol (HTTP/1.1): Authentication
关于HTTP - 多个尾部 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26812057/