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

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