http - 避免 HTTP/1.1 响应的分块编码

标签 http http-headers chunked-encoding

我想避免从(符合标准的)HTTP 服务器获取分块 编码的 HTTP 服务器响应。我正在阅读RFC 261614.39 TE”部分,在我看来我可以通过指定 TE: chunked;q=0 来避免它。如果我无法避免 chunked 编码,我想避免使用预告片。指定 TE: trailers;q=0 会起作用吗?

最佳答案

来自 rfc2616 - Hypertext Transfer Protocol -- HTTP/1.13.6.1 Chunked Transfer Coding 部分:

All HTTP/1.1 applications MUST be able to receive and decode the "chunked" transfer-coding, and MUST ignore chunk-extension extensions they do not understand.

在更新后的RFC 7230 - Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing中依然如此在 4.1. Chunked Transfer Coding 部分尽管措辞略有不同:

A recipient MUST be able to parse and decode the chunked transfer coding.

所以如果你想符合 HTTP/1.1,你将不得不接受分块编码。


##更新##

至于预告片:我认为如果您不在请求中发送 TE header 字段,符合要求的服务器就不会向您发送任何预告片。如果它仍然发送预告片,您可能会保存以忽略它们(同样是第 3.6.1 节):

A server using chunked transfer-coding in a response MUST NOT use the trailer for any header fields unless at least one of the following is true:

a) the request included a TE header field that indicates "trailers" is acceptable in the transfer-coding of the response, as described in section 14.39; or,

b) the server is the origin server for the response, the trailer fields consist entirely of optional metadata, and the recipient could use the message (in a manner acceptable to the origin server) without receiving this metadata. In other words, the origin server is willing to accept the possibility that the trailer fields might be silently discarded along the path to the client.

关于http - 避免 HTTP/1.1 响应的分块编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18174435/

相关文章:

django - 不要在 HTTP 重定向上传播 header

javascript - HTTP header 使浏览器显示 "save as"对话框并保存文件

java - Jersey 服务器 JSON 响应抛出 MalformedChunkCodingException : Chunked stream ended unexpectedly

java - 如何在 HTTP/1.1 中接收分块响应,同时在 Java/Android 中向服务器发送数据

html - 命名 POST/GET 变量的规则?

http - 如果传输编码是分块的,如何使用java获取http响应中的 block 的大小

javascript - 如何检测禁止的文件下载?

python-3.x - Python请求: chunked post request

java - java与google-app-engine通信时报错302

http - 为什么从磁盘缓存返回http 200代码,响应头中既没有过期也没有缓存控制?