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

Content-Encoding与Content-Type的区别的更多相关文章

  1. Content encoding error问题解决方法

    A few people have been experiencing the following error. UPDATE: The reason for it happening is beca ...

  2. Jmeter学习——http请求Content encoding的重要性

    今天在测试一个接口的时候,遇到的问题,困扰了我一天 下面是一个接口,使用的是post请求,Content-Type为application/json 返回参数如下: 瞬间懵逼了!!!为什么呢?渠道是存 ...

  3. Content Provider Basics ——Content Provider基础

    A content provider manages access to a central repository of data. A provider is part of an Android ...

  4. 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. 我 ...

  5. 转:AutoLayout中的Content Hugging 和 Content Compression Resistance

    OS6中引入了AutoLayout,极大的方便了UI元素的布局,现在已经过去一年了,并且大部分设备的系统也已经升级到了iOS6,是时候要使用此项技术了. 在AutoLayout的学习中有两个概念官方文 ...

  6. one-hot encoding与哑变量的区别

    one-hot encoding与哑变量的区别 one-hot比哑变量的特征位多一位,即哑变量是精简版的one-hot,即在线性回归中用截距项来表示最后一维,但由于最初很难分辨特征的主次关系,且机器学 ...

  7. ASP.NET控件<ASP:Button /> html控件<input type="button">区别联系

    ASP.NET控件<ASP:Button />-------html控件<input type="button">杨中科是这么说的:asp和input是一样 ...

  8. Html中,id、name、class、type的区别

    <input type="text" name="name" id="name" class="txt"> ...

  9. isinstance与type的区别

    1.isinstance()内置函数 python中的isinstance()函数是python的内置函数,用来判断一个函数是否是一个已知类型.类似type. 2.用法: isinstance(obj ...

  10. iOS开发 - Content hugging priority & Content compression resistance priority

    1. 什么是Content hugging priority 你可以把它想象成一根放在视图上的橡皮筋. 这根橡皮筋会组织视图超过它本身的固有大小(intrinsic content size). 它存 ...

随机推荐

  1. springcloud(十一):服务网关Zuul高级篇

    时间过的很快,写springcloud(十):服务网关zuul初级篇还在半年前,现在已经是2018年了,我们继续探讨Zuul更高级的使用方式. 上篇文章主要介绍了Zuul网关使用模式,以及自动转发机制 ...

  2. HDU 3167 KMP

    很久之前做的一题,忽然想起来,依然觉得思路巧妙. //这道题,确实是一道好题.但如何应用KMP,确实大大超出了意料中. //这道题匹配的是某元素在子串中的名次,也就是在子串中排第几小.我想了整整一天, ...

  3. 高仿QQ6.0之側滑删除

    前两天已经完毕了高仿QQ6.0側滑和优化,今天来看下側滑删除的实现吧,假设有兴趣,能够去看下之前的两篇,仿QQ6.0側滑之ViewDragHelper的使用(一)和高仿QQ6.0側滑菜单之滑动优化(二 ...

  4. Android热更新实现原理

    最近Android社区的氛围很不错嘛,连续放出一系列的android动态加载插件和热更新库,这篇文章就来介绍一下Android中实现热更新的原理. ClassLoader 我们知道Java在运行时加载 ...

  5. EOJ 3194 字符串消除

    给定一个由大写字母’A’.’B’.’C’构成的字符串s,按如下进行消除过程: 1.字符串s中连续相同字母组成的子串,如果子串的长度大于1,那么这些子串会被同时消除,余下的字符拼成新的字符串. 例如:” ...

  6. 包教包会:本地推送 & 远程推送

    什么是推送?注意,和我们常用的抽象通知不同(NSNotification): 可以让不在前台运行的app,告知用户app内部发生了什么事情:或者没有运行的app接收到服务器发来的通知..比如离线QQ接 ...

  7. 基于Spark的网站日志分析

    本文只展示核心代码,完整代码见文末链接. Web Log Analysis 提取需要的log信息,包括time, traffic, ip, web address 进一步解析第一步获得的log信息,如 ...

  8. php导出mysql源码

    件名:db_backup.php 源代码如下: 复制代码 代码如下: <?php ini_set("max_execution_time", "180") ...

  9. springCloud多模块打包时报错问题

    执行mvn clean package spring-boot:repackage,报错如下: [ERROR] Failed to execute goal org.springframework.b ...

  10. mysql行列转置

    --创建行转列表及插入数据 create table tb_RowConvertToColumn ( username nvarchar(100) null, course nvarchar(100) ...