Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1481480
  • 博文数量: 228
  • 博客积分: 1698
  • 博客等级: 上尉
  • 技术积分: 3241
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-24 21:49
个人简介

Linux

文章分类

全部博文(228)

文章存档

2017年(1)

2016年(43)

2015年(102)

2014年(44)

2013年(5)

2012年(30)

2011年(3)

分类: 系统运维

2015-05-14 16:01:49

原文地址:HTTP1.0-1.1差异 作者:cbin_07

HTTP1.1-1.0差别

备注:本文主要基于HTTP1.1规范的角度进行两个版本的对比。

Protocol Parameters

Date/Time Formats

(接收方向)

无论是HTTP1.0还是HTTP1.1,都要能解析下面三种date/time stamp

Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123

Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036

Sun Nov  6 08:49:37 1994       ; ANSI C's asctime() format

(发送方向)

HTTP1.0要求不能生成第三种asctime格式的date/time stamp

HTTP1.1则要求只生成RFC 1123(第一种)格式的date/time stamp

Content Codings

HTTP1.1支持:

gzipcompressdeflatezlib格式)

HTTP1.0支持:

gzipcompress

Transfer Codings

HTTP1.1

支持chunked transfer,所以可以有Transfer-Encoding头部域:

Transfer-Encoding: chunked

备注:(详见rfc2616-3.6.1

chunked 编码修饰消息的主体,为了以一系列的大块传输它,每块都有它自己的大小指示符,接在【可选】的包含实体头部域的尾巴后。这允许动态生成的内容与必要信息一起传输,以便接收者检验它已经接收完全部的消息。

Quality Values

HTTP1.1

HTTP 内容协商(12 )使用简短的“浮点”数来指出各种协商参数的相对重要性(“权重”。权重通常是 0 1 范围内的实数,这里 0 是最小的,1 是最大的。如果某个参数的质) 量值为 0,则该参数对于该客户来说“不可接受”。

Entity Tags

HTTP1.1

实体标签用来从相同的请求资源来比较两个或多个实体。HTTP/1.1ETagIf-MatchIf-None-MatchIf-Range头部域中使用实体 标签。这几个标签在HTTP in Cache中使用。

Range Units

HTTP1.1

允许客户端只请求响应实体的某部分包含在响应中。HTTP/1.1 Range Content-Range头部域中使用范围单位。实体可以依据各种结构

化单位分割为子范围。

bytes-unit = "bytes"

other-range-unit = token

HTTP/1.1 定义的唯一范围单位是“bytes”

HTTP Message

General Header Fields

红色为HTTP1.1新增:

general-header = Cache-Control ; Section 14.9

                      | Connection               ; Section 
                      | Date                     ; Section 
                      | Pragma                   ; Section 
                      | Trailer                  ; Section 
                      | Transfer-Encoding        ; Section 
                      | Upgrade                  ; Section 
                      | Via                      ; Section 
                      | Warning                  ; Section 

Request

Method

红色为HTTP1.1新增:

Method         = "OPTIONS"                ; Section 9.2
                      | "GET"                    ; Section 
                      | "HEAD"                   ; Section 
                      | "POST"                   ; Section 
                      | "PUT"                    ; Section 
                      | "DELETE"                 ; Section 
                      | "TRACE"                  ; Section 
                      | "CONNECT"                ; Section 
                      | extension-method

Request Header Fields

红色为HTTP1.1新增:

 request-header = Accept                   ; Section 14.1
                      | Accept-Charset           ; Section 
                      | Accept-Encoding          ; Section 
                      | Accept-Language          ; Section 
                      | Authorization            ; Section 
                      | Expect                   ; Section 
                      | From                     ; Section 
                      | Host                     ; Section 
                      | If-Match                 ; Section 
                      | If-Modified-Since        ; Section 14.25
                      | If-None-Match            ; Section 
                      | If-Range                 ; Section 
                      | If-Unmodified-Since      ; Section 
                      | Max-Forwards             ; Section 
                      | Proxy-Authorization      ; Section 
                      | Range                    ; Section 
                      | Referer                  ; Section 
                      | TE                       ; Section 
                      | User-Agent               ; Section 

Response

Status Code

红色为HTTP1.1新增:

Status-Code    =
            "100"  ; Section : Continue
          | "101"  ; Section : Switching Protocols
          | "200"  ; Section : OK
          | "201"  ; Section : Created
          | "202"  ; Section : Accepted
          | "203"  ; Section : Non-Authoritative Information
          | "204"  ; Section : No Content
          | "205"  ; Section : Reset Content
          | "206"  ; Section : Partial Content
          | "300"  ; Section : Multiple Choices
          | "301"  ; Section : Moved Permanently
          | "302"  ; Section : Found(与HTTP1.0中的302意义不一样)
          | "303"  ; Section : See Other
          | "304"  ; Section : Not Modified
          | "305"  ; Section : Use Proxy
          | "307"  ; Section : Temporary Redirect
          | "400"  ; Section : Bad Request
          | "401"  ; Section : Unauthorized
          | "402"  ; Section : Payment Required
          | "403"  ; Section : Forbidden
          | "404"  ; Section : Not Found
          | "405"  ; Section : Method Not Allowed
          | "406"  ; Section : Not Acceptable
          | "407"  ; Section 10.4.8: Proxy Authentication Required
          | "408"  ; Section : Request Time-out
          | "409"  ; Section : Conflict
          | "410"  ; Section : Gone
          | "411"  ; Section : Length Required
          | "412"  ; Section : Precondition Failed
          | "413"  ; Section : Request Entity Too Large
          | "414"  ; Section : Request-URI Too Large
          | "415"  ; Section : Unsupported Media Type
          | "416"  ; Section : Requested range not satisfiable
          | "417"  ; Section : Expectation Failed
          | "500"  ; Section : Internal Server Error
          | "501"  ; Section : Not Implemented
          | "502"  ; Section : Bad Gateway
          | "503"  ; Section : Service Unavailable
          | "504"  ; Section : Gateway Time-out
          | "505"  ; Section : HTTP Version not supported
          | extension-code

Response Header Fields

红色为HTTP1.1新增:

response-header = Accept-Ranges           ; Section 14.5
                       | Age                     ; Section 
                       | ETag                    ; Section 
                       | Location                ; Section 
                       | Proxy-Authenticate      ; Section 
                       | Retry-After             ; Section 14.37
                       | Server                  ; Section 
                       | Vary                    ; Section 
                       | WWW-Authenticate        ; Section 

Entity

Entity Header Fields

红色为HTTP1.1新增:

entity-header  = Allow                    ; Section 14.7
                      | Content-Encoding         ; Section 
                      | Content-Language         ; Section 
                      | Content-Length           ; Section 
                      | Content-Location         ; Section 
                      | Content-MD5              ; Section 
                      | Content-Range            ; Section 
                      | Content-Type             ; Section 
                      | Expires                  ; Section 
                      | Last-Modified            ; Section 
                      | extension-header

Connection

Persistent connection

HTTP1.1

支持persistent connection,并且默认使用

HTTP1.0

支持persistent connection需要显性增加Connection: Keep-Alive header,默认不使用

Pipelining

HTTP1.1

支持永久连接的客户端<可以>按“管道”方式请求(如,发送多个请求而不需等待每个响应)。服务器<必须>必须以收到请求的相同顺序来响应发送这些请求的响应。

Caching in HTTP

HTTP1.1

完整的cache管理机制,引入Expiration ModelValidation Model模型

HTTP1.0

只包括几种cache处理机制:no-cache\If-Modified-Since\Last-Modified\Expires,只是通过简单的计算时间进行处理

备注:详细情况参见参考文献【2】。

总结

从对比HTTP1.11.0的情况看有如下几个需要注意的特性:

业务相关

  • Range机制

该机制提供基于range的请求,如果我们的CDN后续需要引入视频等业务时,则在我们的CDN系统中必须支持该特性。

功能相关

  • Cache机制

HTTP1.1Cache机制远比1.0复杂和高效,在我们的Cache系统中主要注意兼容性问题。

  • Chunk编码机制

Chunk编码机制在需要输出动态内容时可以有效的提高用户体验,让用户及时的得到部分数据。

性能相关

  • Persistent Connection

  • Pipeline

参考文献

1rfc2616

2rfc1945

阅读(1352) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~