gpt4 book ai didi

http - 为什么传输编码 :Chunked sent instead of Content-Encoding:gzip for some of clients?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:28:29 24 4
gpt4 key购买 nike

我很困惑。我有两台笔记本电脑通过相同的调制解调器设备连接到互联网。对于在其中启用 gzip 的 Web 服务器,例如 microsoft.com,我的一个系统(64 位)使用 Transfer-Encoding:chunked< 获取响应 header 。另一个使用 Content-Encoding:gzip 以正确的形式获取响应 header 。为什么?两个系统都有 Windows 7 SP1(其中一个是 32 位的,另一个是 64 位的)。我在两个系统上使用相同版本的 Chrome 进行了测试。我还使用 FireFox 和 IE 进行了测试。

最佳答案

因为在传输编码中不需要将要传输的分块内容长度。数据被分成几部分并通过网络发送。

来自 the Wikipedia page :

Chunked transfer encoding is a data transfer mechanism in version 1.1 of the Hypertext Transfer Protocol (HTTP) in which data is sent in a series of "chunks". It uses the Transfer-Encoding HTTP header in place of the Content-Length header, which the earlier version of the protocol would otherwise require. Because the Content-Length header is not used, the sender does not need to know the length of the content before it starts transmitting a response to the receiver. Senders can begin transmitting dynamically-generated content before knowing the total size of that content.

The size of each chunk is sent right before the chunk itself so that the receiver can tell when it has finished receiving data for that chunk. The data transfer is terminated by a final chunk of length zero.

Encoded data

In the following example, every second line is the start of a new chunk, with the chunk size as a hexadecimal number followed by \r\n as a line separator.

4\r\n
Wiki\r\n
5\r\n
pedia\r\n
e\r\n
in\r\n\r\nchunks.\r\n
0\r\n
\r\n

Note: the chunk size indicates the size of only the chunk data. This does not include the trailing CRLF ("\r\n") at the end of the counted characters. In this particular example, the CRLF following "in" is counted 2 toward the chunk length of 0xE (14), and the CRLF in its own line is also counted 2 toward the chunk length of 0xE (14). The period character at the end of "chunks" is the 14th character, so it is the last character of the chunk of length 0xE (14). The CRLF following the period is the trailing CRLF, so it is not counted toward the chunk length of 0xE (14).

Decoded data

Wikipedia in

chunks.

关于http - 为什么传输编码 :Chunked sent instead of Content-Encoding:gzip for some of clients?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32204517/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com