这个GET响应Content-Length如何计算?

时间:2013-09-24 02:16:24

标签: http get http-content-length

响应标头是:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-IIS/8.0
X-AspNetMvc-Version: 4.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?RDpcTkVUXFRlc3RcTXZjQXBwbGljYXRpb25UZXN0XGhvbWVcR2V0VGVzdA==?=
X-Powered-By: ASP.NET
Date: Tue, 24 Sep 2013 02:06:35 GMT
Content-Length: 129

并且回复是:

This is a get

如图: enter image description here

enter image description here

我想知道内容长度:129计算,谢谢!

1 个答案:

答案 0 :(得分:4)

Content-Length标头包含响应主体的大小(即标头之后的数据),以字节为单位。

在上面的示例中,使用了gzip压缩,因此129字节表示字符串“This is a get”需要使用gzip压缩传输129个字节。虽然压缩旨在减少有效负载大小,但对于非常小的内容体或者内容已经被压缩(例如图像),它可能会产生相反的效果;

http://www.httpwatch.com/httpgallery/compression/

此博客文章介绍了如何在HTTP响应中处理内容长度:

http://www.httpwatch.com/httpgallery/chunked/

相关问题