博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Content-Encoding与Content-Type的区别
阅读量:6479 次
发布时间:2019-06-23

本文共 2535 字,大约阅读时间需要 8 分钟。

 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 applicationContent-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".

转载地址:http://puwuo.baihongyu.com/

你可能感兴趣的文章
RDD之五:Key-Value型Transformation算子
查看>>
percona 5.7.11root初始密码设置
查看>>
Cognitive Security的异常检测技术
查看>>
Impress.js上手 - 抛开PPT、制作Web 3D幻灯片放映
查看>>
生活杂事--度过十一中秋
查看>>
Pyrex也许是一个好东西
查看>>
WINFORM WPF字体颜色相互转换
查看>>
能力不是仅靠原始积累(三)
查看>>
实战:使用终端服务网关访问终端服务
查看>>
彻底学会使用epoll(一)——ET模式实现分析
查看>>
【Android 基础】Android中全屏或者取消标题栏
查看>>
脱离标准文档流(2)---定位
查看>>
IO流之字符流
查看>>
集合异常之List接口
查看>>
Softmax回归
查看>>
紫书 习题11-11 UVa 1644 (并查集)
查看>>
App工程结构搭建:几种常见Android代码架构分析
查看>>
使用openssl进行证书格式转换
查看>>
ZOJ 3777 Problem Arrangement
查看>>
Callable和Future
查看>>