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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值