使用http压缩时的内容长度 [英] content-length when using http compression

查看:125
本文介绍了使用http压缩时的内容长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

客户端正在向http服务器发出范围请求0-1023。它更喜欢gzip压缩与
Accept-Encoding:gzip; q = 1.0,identity;请求中q = 0.5,*; q = 0

The client is making a range request 0-1023 to the http server. It prefers gzip compression with Accept-Encoding: gzip;q=1.0, identity; q=0.5, *;q=0 in the request.

响应头中的内容长度是多少?它是1024还是压缩数据的大小。

What would be the content-length in the response header? Will it be 1024 or the size of the compressed data.

谢谢,

推荐答案

它是1024或压缩的较小者大小。

It's the smaller of 1024 or the compressed size.

RFC2616部分14 说:


[这个答案的其余部分与实际提出的问题没有关系。我将其留下来,因为一些人们发现它很有用。]

" [ The rest of this answer has no relevance to the actual question asked. I'm leaving it in because some people found it useful. ]

RFC 2616有关于内容长度的说法(除其他事项外):

RFC 2616 has this to say (amongst other things) about Content-Length:

应用程序应该使用此字段来指示消息体的
的传输长度,除非
4.4节中的规则禁止这样做。

Applications SHOULD use this field to indicate the transfer-length of the message-body, unless this is prohibited by the rules in section 4.4.

所以我们必须弄清楚转移长度是多少; 第4.4节(消息长度)说这两个关于转移长度的事情:

So we have to figure out what transfer-length is; Section 4.4 (Message Length) says these two things about transfer-length:


transf消息的长度是消息体的长度,它显示在消息中;
;也就是说,在任何转移编码已经应用了
之后。

The transfer-length of a message is the length of the message-body as it appears in the message; that is, after any transfer-codings have been applied.

如果存在Content-Length头字段(第14.13节),则其
OCTET中的十进制值表示实体长度和
传输长度。如果
这两个长度不同,则不得发送Content-Length头字段

If a Content-Length header field (section 14.13) is present, its decimal value in OCTETs represents both the entity-length and the transfer-length. The Content-Length header field MUST NOT be sent if these two lengths are different

好的,所以我们知道这种情况下,transfer-length,entity-length和Content-Length都具有相同的值,并且都指的是消息体显示在消息中的长度,因此我们必须确定什么是消息体是。 第4.3节说明了关于message-body:

Okay, so we know that in this case transfer-length, entity-length, and Content-Length all have the same value, and all refer to "the length of the message-body as it appears in the message", and so we have to determine what message-body is. Section 4.3 says this about message-body:


HTTP消息的消息体(如果有)用于携带与请求或响应关联的
实体体。

The message-body (if any) of an HTTP message is used to carry the entity-body associated with the request or response."

那么什么是实体体?为此你必须基本上所有的第7节。(这也定义了实体长度。)最重要的是,有:

So what's an entity-body? For that you have to refer to basically all of Section 7. (Which also defines entity-length.) Most importantly, there this:


entity-body:= Content-Encoding(Content-Type(data))

entity-body := Content-Encoding( Content-Type( data ) )

实体主体的长度(因此我们的每4.4内容长度的值)是内容编码后数据的长度。

The length of the entity-body (and therefore our value for Content-Length per 4.4) is the length of the data after content-coding.

这篇关于使用http压缩时的内容长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆