RFC 2616 for HTTP 1.1 specifies how web servers must indicate encoding transformations using the Content-Encoding header. Although on the surface, Content-Encoding (e.g., gzip, deflate, compress) and Content-Type(e.g., x-application/x-gzip) sound similar, they are, in fact, two distinct pieces of information. Whereas servers use Content-Type to specify the data type of the entity body, which can be useful for client applications that want to open the content with the appropriate application, Content-Encoding is used solely to specify any additional encoding done by the server before the content was transmitted to the client. Although the HTTP RFC outlines these rules pretty clearly, some web sites respond with "gzip" as the Content-Encoding even though the server has not gzipped the content.
Our testing has shown this problem to be limited to some sites that serve Unix/Linux style "tarball" files. Tarballs are gzip compressed archives files. By setting the Content-Encoding header to "gzip" on a tarball, the server is specifying that it has additionally gzipped the gzipped file. This, of course, is unlikely but not impossible or non-compliant.
Therein lies the problem. A server responding with content-encoding, such as "gzip," is specifying the necessary mechanism that the client needs in order to decompress the content. If the server did not actually encode the content as specified, then the client's decompression would fail.
-----------------------------------来自RFC2616--------------------------------------
When an entity-body is included with a message, the data type of that
body is determined via the header fields Content-Type and Content-
Encoding. These define a two-layer, ordered encoding model:
entity-body := Content-Encoding( Content-Type( data ) )
Content-Type specifies the media type of the underlying data.
Content-Encoding may be used to indicate any additional content
codings applied to the data, usually for the purpose of data
compression, that are a property of the requested resource. There is
no default encoding.
Any HTTP/1.1 message containing an entity-body SHOULD include a
Content-Type header field defining the media type of that body. If
and only if the media type is not given by a Content-Type field, the
recipient MAY attempt to guess the media type via inspection of its
content and/or the name extension(s) of the URI used to identify the
resource. If the media type remains unknown, the recipient SHOULD
treat it as type "application/octet-stream".
分享到:
相关推荐
设置内容类型设置给定请求和响应对象的 Content-Type 标头安装$ npm install set-content-type用法 var setContentType = require ( 'set-content-type' )setContentType ( request , response )
下例是一个邮件的标准MIME头: Mime-Version: 1.0 //版本号:1.0 Content-Type: multipart/mixed; boundary="IMA.Boundary...Content-Transfer-Encoding: 7bit //编码方式:7位 Content-Description: cc:Mail note part
response header一般都是以key:value的形式,例如:“Content-Encoding:gzip、Cache-Control:no-store”,设置的命令为: 代码如下:add_header Cache-Control no-storeadd_header Content-Encoding gzip ...
17 Content-Type 21 18 Date 22 1没有时钟的源服务器运作 22 19 ETag 23 20 Expect 23 21 Expires 23 22 From 24 23 Host 24 24 If-Match 25 25 If-Modified-Since 26 26 If-None-Match 27 27 If-Range 28 28 If-...
cvc-complex-type.2.4.a: Invalid content was found starting with element 'page-encoding'. One of '{"http:// java.sun.com/xml/ns/javaee":include-prelude, ...
my $msg=MIME::Lite->new( From=>$opt->{from}, To=>$opt->{to}, #Subject=>$opt->{subject}, ...$msg->attr("content-type.charset" => "UTF-8"); #$msg->send('smtp','wwww.maildir.cn',Debug=>0);
...Host: localhost ...Content-Type: text/xml; charset=utf-8 Content-Length: length <?xml version="1.0" encoding="utf-8"?> <short xmlns="http://webi.org">short*/ //出参是json格式{"statusCode":"2"}
前言 大家都知道,nginx配置文件通过使用...content-type: text/html; charset=UTF-8 vary: Accept-Encoding, Cookie cache-control: max-age=3, must-revalidate last-modified: Thu, 07 Feb 2019 03:54:54 GMT X-Cach
今天在调取一家商城的页面信息时候,使用...类似的信息,即Content-Encoding为gzip,即该站点开启了gzip压缩。这里的解决方案有多种,当然如果你使用file_get_contents的话,可以这样修改: 复制代码 代码如下: file
X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block 如果设置了Content-Security-Policy或仅Content-Security-Policy-Report-Only 如果设置了Content-Security-Policy: upgrade-insecure-...
常见的标准标头是Server,Content-Encoding,Content-Type,Content-Length,Expires,Cache-control等。常见的非标准响应标头是X-Powered-By,X-Version,X-Runtime,X-Version,X -缓存,X-AspNet版本,X-XSS保护...
安装 npm install -g s3upload特征Content-Type是根据文件扩展名设置的,因此example.png将获得Content-Type“ image / png” 将可压缩文件(根据模块)压缩并正确设置Content-Encoding 上载时,您可以使用全局名称...
该项目应该是HTTP 1.1中定义的基于HTTP的内容协商的实现,包括协商轴Content-Type,Charset,Content-Language和Content-Encoding。 它使用相应的HTTP标头。
Content-Type: application/x-www-form-urlencoded Content-Length: 200 Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727) Host: bbs....
复制代码 代码如下:<... header(‘Content-Type: application/octet-stream’); header(‘Content-Disposition: attachment; filename=’.basename($file)); header(‘Content-Transfer-Encoding: binary’); heade
休息服务简单的 REST JSON/XML Web 服务。...HTTP/1.1 200 OKSet-Cookie: USER_ID=40ab2e72-36e5-4273-b29a-d2439a027e27Content-Type: application/jsonTransfer-Encoding: chunkedServer: Jetty(6.1.25){"count":
Content-Type:application/json; charset=utf-8 Server:Kestrel Transfer-Encoding:chunked Location:http://localhost:5000/api/companies/61156544-d8bd-4787-a79a-a484dd9a382c 在浏览器中输入...
-T content-type Content-type header to use for POST/PUT data, eg. 'application/x-www-form-urlencoded' Default is 'text/plain' -v verbosity How much troubleshooting info to print -w Print out ...
Response.AddHeader("content-type", "application/x-msdownload;"); Response.AddHeader("Content-Disposition", "attachment;filename=" + filename); Response.AddHeader("content-length", size.ToString());...
1、断点续传的原理(来自网络) ... 请求协议是由客户机(浏览器)向...Content-Type: image/jpeg Accept-Ranges: bytes Last-Modified: Thu, 23 May 2002 03:05:40 GMT ETag: "bec48eb862c21:934" Content-Length: 2827