HTTP1.1和HTTP1.0的區別

HTTP1.1和HTTP1.0的區別

 


翻了下HTTP1.1的協議標準RFC2616,下面是看到的一些它跟HTTP1.0的差別。

 

Persistent Connection(持久連接)

HTTP1.0中,每對Request/Response都使用一個新的連接。

HTTP 1.1則支持Persistent Connection, 並且默認使用persistent connection.

 

Host 

 

HTTP1.1Request消息頭裏頭多了一個Host域,比如:

 

       GET /pub/WWW/TheProject.html HTTP/1.1

       Host: www.w3.org

  

   HTTP1.0則沒有這個域。

   可能HTTP1.0的時候認爲,建立TCP連接的時候已經指定了IP地址,這個IP地址上只有一個host

 

date/time stamp (日期時間戳)

(接收方向)

無論是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

 

 

 

Transfer Codings

 

HTTP1.1支持chunked transfer,所以可以有Transfer-Encoding頭部域:

Transfer-Encoding: chunked

 

   HTTP1.0則沒有。

 

 

Quality Values

 

HTTP1.1多了個qvalue域:

 

       qvalue         = ( "0" [ "." 0*3DIGIT ] )

                      | ( "1" [ "." 0*3("0") ] )

 

 

Entity Tags

   

用於Cache

 

 

Range  Content-Range

 

HTTP1.1支持傳送內容的一部分。比方說,當客戶端已經有內容的一部分,爲了節省帶寬,可以只向服務器請求一部分。

 

 

100 (Continue) Status

 

100 (Continue) 狀態代碼的使用,允許客戶端在發request消息body之前先用request header試探一下server,看server要不要接收request body,再決定要不要發request body

客戶端在Request頭部中包含

Expect: 100-continue

Server看到之後呢如果回100 (Continue) 這個狀態代碼,客戶端就繼續發request body

 

這個是HTTP1.1纔有的。

 

 

Request method

 

HTTP1.1增加了OPTIONS, PUT, DELETE, TRACE, CONNECT這些Request方法.

 

       Method         = "OPTIONS"                ; Section 9.2

                      | "GET"                    ; Section 9.3

                      | "HEAD"                   ; Section 9.4

                      | "POST"                   ; Section 9.5

                      | "PUT"                    ; Section 9.6

                      | "DELETE"                 ; Section 9.7

                      | "TRACE"                  ; Section 9.8

                      | "CONNECT"                ; Section 9.9

                      | extension-method

       extension-method = token

 

 

Status code

 

  HTTP1.1 增加的新的status code

 

(HTTP1.0沒有定義任何具體的1xx status code, HTTP1.12)

100 Continue

101 Switching Protocols

 

203 Non-Authoritative Information

205 Reset Content

206 Partial Content

 

302 Found (HTTP1.0中有個 302 Moved Temporarily)

303 See Other

305 Use Proxy

307 Temporary Redirect

 

405 Method Not Allowed

406 Not Acceptable

407 Proxy Authentication Required

408 Request Timeout

409 Conflict

410 Gone

411 Length Required

412 Precondition Failed

413 Request Entity Too Large

414 Request-URI Too Long

415 Unsupported Media Type

416 Requested Range Not Satisfiable

417 Expectation Failed

 

504 Gateway Timeout

505 HTTP Version Not Supported

 

 

 

Content Negotiation

 

    HTTP1.1增加了Content Negotiation,分爲Server-driven NegotiationAgent-driven NegotiationTransparent Negotiation三種。

 

 

Cache (緩存)

 

HTTP1.1(RFC2616)詳細展開地描述了Cache機制,詳見13節。

依據:

rfc2616 Hypertext Transfer Protocol -- HTTP-1.1.txt

rfc1945 Hypertext Transfer Protocol -- HTTP 1.0.txt

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章