Content-Encoding与Content-Type的区别
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-Encoding与Content-Type的区别的更多相关文章
- Content encoding error问题解决方法
A few people have been experiencing the following error. UPDATE: The reason for it happening is beca ...
- Jmeter学习——http请求Content encoding的重要性
今天在测试一个接口的时候,遇到的问题,困扰了我一天 下面是一个接口,使用的是post请求,Content-Type为application/json 返回参数如下: 瞬间懵逼了!!!为什么呢?渠道是存 ...
- Content Provider Basics ——Content Provider基础
A content provider manages access to a central repository of data. A provider is part of an Android ...
- Django 报错 Reverse for 'content' not found. 'content' is not a valid view function or pattern name.
Django 报错 Reverse for 'content' not found. 'content' is not a valid view function or pattern name. 我 ...
- 转:AutoLayout中的Content Hugging 和 Content Compression Resistance
OS6中引入了AutoLayout,极大的方便了UI元素的布局,现在已经过去一年了,并且大部分设备的系统也已经升级到了iOS6,是时候要使用此项技术了. 在AutoLayout的学习中有两个概念官方文 ...
- one-hot encoding与哑变量的区别
one-hot encoding与哑变量的区别 one-hot比哑变量的特征位多一位,即哑变量是精简版的one-hot,即在线性回归中用截距项来表示最后一维,但由于最初很难分辨特征的主次关系,且机器学 ...
- ASP.NET控件<ASP:Button /> html控件<input type="button">区别联系
ASP.NET控件<ASP:Button />-------html控件<input type="button">杨中科是这么说的:asp和input是一样 ...
- Html中,id、name、class、type的区别
<input type="text" name="name" id="name" class="txt"> ...
- isinstance与type的区别
1.isinstance()内置函数 python中的isinstance()函数是python的内置函数,用来判断一个函数是否是一个已知类型.类似type. 2.用法: isinstance(obj ...
- iOS开发 - Content hugging priority & Content compression resistance priority
1. 什么是Content hugging priority 你可以把它想象成一根放在视图上的橡皮筋. 这根橡皮筋会组织视图超过它本身的固有大小(intrinsic content size). 它存 ...
随机推荐
- 【codeforces 509E】Pretty Song
[题目链接]:http://codeforces.com/contest/509/problem/E [题意] 让你计算一个字符串的所有子串里面元音字母出现的频率的和; [题解] 先处理出前缀和-&g ...
- 数字统计(2010年NOIP全国联赛普及组)
题目描述 请统计某个给定范围[L, R]的所有整数中,数字 2 出现的次数. 比如给定范围[2, 22],数字 2 在数 2 中出现了 1 次,在数 12 中出现 1 次,在数 20 中出 现 1 次 ...
- 利用rsync如何同步单个文件
rsync -vzrtopg --progress --include-from=/home/test/include.list --exclude=/* root@192.168.30.179::b ...
- 小记——GTMD校园网
前言 学校一年前开通了校园网,然鹅信号未覆盖我们住的公寓,又多忍受了一年的小破宽带(10M带宽,100块300个小时) 上个星期,架设了一年的校园网终于通了,然后我们发现——校园网69元一个月,一个用 ...
- webpack教程——css的加载
首先要安装css的loader npm install css-loader style-loader --save-dev 然后在webpack.config.js中配置如下代码 意思是先用css- ...
- Clojure:从Java调用Clojure
我们要在Java中调用Clojure有两种方法,一种是将Clojure代码生成class文件,另外一种是通过Clojure RT方式直接在java程序中调用Clojure代码.两种方式各有优缺点, 第 ...
- nyoj891(区间上的贪心)
题目意思: 给一些闭区间,求最少须要多少点,使得每一个区间至少一个点. http://acm.nyist.net/JudgeOnline/problem.php?pid=891 例子输入 4 1 5 ...
- jQuery Validate 使用
jQuery Validate 使用 <script src="js/b/js/jquery.validate.js"></script> <styl ...
- Hive权限之审计
因为在生产环境中大量使用hive.而hive的权限又较弱,假设可以记录全部hive操作,在增强安全性的同一时候,还可以统计hive表的使用频率:同一时候假设可以记录hql的開始和结束时间,则可以找出系 ...
- http自己定义超时检測方法、主动抛出异常
上次为了解决无网路由器超时的问题,将问题重心转移到了HttpClient. HttpUrLConnection上面,什么各种设置ReadTimeout. connectionTimeOut,还有所谓的 ...