Http1.0与Http1.1的区别

Http1.0与Http1.1的区别

 

今天在写一个段代理程序的时候,发现了一个奇怪的问题,在返回的数据中,当接完头部分然后\n\n之后出现了3位16进制的值,然后是数据段,在结尾还多了一个0, 造成输出的数据有误,在仔细查看后发现是 http1.0 与 http1.1协议不同造成,问题仍未找到,下面有个链接是关于 HTTP两个协议之间的区别的:

 

http://www.research.att.com/~bala/papers/h0vh1.html

http://s2.9mmo.com/tech/viewthread.php?tid=4454&extra=

 

The Chunked transfer-coding

HTTP/1.1 resolves the problem of delimiting message bodies by introducing the Chunked transfer-coding. The sender breaks the message body into chunks of arbitrary length, and each chunk is sent with its length prepended; it marks the end of the message with a zero-length chunk. The sender uses the Transfer-Encoding: chunked header to signal the use of chunking.

 

This mechanism allows the sender to buffer small pieces of the message, instead of the entire message, without adding much complexity or overhead. All HTTP/1.1 implementations must be able to receive chunked messages.

 

The Chunked transfer-coding solves another problem, not related to performance. In HTTP/1.0, if the sender does not include a Content-Length header, the recipient cannot tell if the message has been truncated due to transmission problems. This ambiguity leads to errors, especially when truncated responses are stored in caches.

 

it marks the end of the message with a zero-length chunk

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章