posts - 13,  comments - 4,  trackbacks - 0

          一、介紹(introduction)

          1. 目的——HTTP/0.9-〉HTTP/1.0-〉HTTP/1.1

          2. 要求——MUST、REQUIRED、SHOULD

          3. 術語——連接(Connection)、消息(Message)、請求(Request)、應答(Response)、資源(Resource)、實體 (Entity)、表示方法(Representation)、內容協商(Content Negotiation)、變量(Variant)、客戶機(Client)、用戶代理(User agent)、服務器(Server)、原服務器(Origin server)、代理服務器( Proxy)、網關(gateway)、高速緩存(Cache)、可緩存(Cacheable)、直接(first-hand)、明確終止時間 (explicit expiration time)、探索終止時間(heuristic expiration time)、年齡(Age)、保鮮壽命(Freshness lifetime)、保鮮(Fresh)、陳舊(Stale)、語義透明(semantically transparent)、有效性判別器(Validator)、實體標記(entity tag)或最終更改時間(Last-Modified time))、上游/下游(upstream/downstream)、向內/向外(inbound/outbound)

          4. 總體操作——請求/應答、中介

          二、符號慣例與一般語法(notational conversions and generic grammar)

          1. 擴充BNF——name = definition,"literal",rule1 | rule2,(rule1 rule2),*rule,[rule],N rule, #rule,; comment, implied *LWS

          2. 基本規則——OCTET,CHAR,UPALPHA,LOALPHA,ALPHA,DIGIT,CTL,CR,LF,SP,HT,<">

          三、協議參數(protocol parameters)

          1. HTTP版本——HTTP-Version = "HTTP" "/" 1*DIGIT "." 1*DIGIT

          2. 統一資源標示符(URI)——統一資源定位器(URL)和統一資源名稱(URN)的結合,http_URL = "http:" "http://" host [ ":" port ] [ abs_path [ "?" query ]]

          3. 日期/時間格式——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

          4. 字符集——本文檔中的術語"字符集"指一種用一個或更多表格將一個八字節序列轉換成一個字符序列的方法,
          charset=token
          失蹤字符集

          5. 內容編碼——內容編碼主要用來允許文檔壓縮(信源編碼)
          content-coding= token
          注冊表包含下列標記:gzip,compress,deflate,identity

          6. 傳輸編碼——目的是能夠確保通過網絡安全傳輸(信道編碼)
          transfer-coding = "chunked" | transfer-extension
          transfer-extension = token *( ";" parameter ),
          成塊傳輸代碼

          7. 媒體類型——media-type = type "/" subtype *( ";" parameter )
          type = token
          subtype = token
          規范化和原文缺省
          多部分類型

          8. 產品標記——product = token ["/" product-version]
          product-version = token

          9. 質量值——qvalue = ( "0" [ "." 0*3DIGIT ] )| ( "1" [ "." 0*3("0") ] )

          10. 語言標記——language-tag = primary-tag *( "-" subtag )
          primary-tag = 1*8ALPHA
          subtag = 1*8ALPHA

          11. 實體標記——entity-tag = [ weak ] opaque-tag
          weak = "W/"
          opaque-tag = quoted-string

          12. 范圍單位——range-unit = bytes-unit | other-range-unit
          bytes-unit = "bytes"
          other-range-unit = token

          四、 HTTP消息(HTTP message)

          1. 消息類型——HTTP-message = Request | Response ; HTTP/1.1 messages
          generic-message = start-line *(message-header CRLF) CRLF [ message-body ]
          start-line = Request-Line | Status-Line

          2. 消息頭——HTTP頭域包括常規頭,請求頭,應答頭和實體頭域
          message-header = field-name ":" [ field-value ]
          field-name = token
          field-value = *( field-content | LWS )
          field-content = <the OCTETs making up the field-value and consisting of either *TEXT or combinations of token, separators, and quoted-string>

          3. 消息體——message-body = entity-body| <entity-body encoded as per Transfer-Encoding>

          4. 消息的長度——決定因素

          5. 常規頭域——general-header = Cache-Control| Connection| Date| Pragma| Transfer-Encoding

          五、 請求(request)

          首行包括利用資源的方式,區分資源的標識,以及協議的版本號
          Request = Request-Line * (( general-header| request-header| entity-header ) CRLF) CRLF [ message-body ]

          1. 請求行——Request-Line = Method SP Request-URI SP HTTP-Version CRLF
          方法——方法標記指的是在請求URI所指定的資源上所實現的方式
          Method = "OPTIONS"| "GET"| "POST"| "PUT"| "DELETE"| "TRACE"| "CONNECT"| extension-method
          extension-method = token
          請求URL——請求URL是一種全球統一的應用于資源請求的資源標識符
          Request-URI = "*" | absoluteURI | abs_path | authority
          請求行舉例:GET http://www.w3.org/pub/WWW/TheProject.html HTTP/1.1
          GET /pub/WWW/TheProject.html HTTP/1.1
          Host: www.w3.org

          2. 請求定義的資源——一個INTERNET請求所定義的精確資源由請求URL和主機報頭域所決定

          3. 請求報頭域——request-header = Accept| Accept-Charset| Accept-Encoding| Accept-Language| Authorization| Expect| From| Host| If-Match| If-Modified-Since| If-None-Match| If-Range| If-Unmodified-Since| Max-Forwards| Proxy-Authorization| Range| Referer| TE| User-Agent

          六、 應答(response)

          接收和翻譯一個請求信息后,服務器發出一個HTTP應答信息
          Response = Status-Line*(( general-header| response-header| entity-header ) CRLF) CRLF [ message-body ]

          1. 狀態行——Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
          狀態碼——狀態碼是試圖理解和滿足請求的三位數字的整數碼,1xx,2xx,3xx,4xx,5xx,100-〉505-〉擴展碼

          2. 應答報頭域——response-header = Accept-Ranges| Age| Location| Proxy-Authenticate| Retry-After| Server| Vary| WWW-Authenticate

          七、 實體(entity)

          在未經特別規定的情況下,請求與應答的消息也可以傳送實體。 實體包括實體報頭域與實體正文,而有些應答只包括實體報頭。

          1. 實體報頭域——entity-header = Allow | Content-Encoding| Content-Language| Content-Length | Content-Location| Content-MD5| Content-Range| Content-Type| Expires| Last-Modified| extension-header
          extension-header = message-header

          2. 實體正文——entity-body = *OCTET
          entity-body := Content-Encoding( Content-Type( data ) )

          八、 連接(connection)

          1. 持續連接——優點
          持續連接是任何HTTP連接的缺省方式,支持持續連接的客戶機可以以流水線方式發送請求
          代理服務器

          2. 消息傳遞要求——持續連接與流量控制
          監視連接中出錯狀態的消息
          100號狀態的用途
          服務器過早關閉連接時客戶機的動作

          九、 方法定義(method definitions)

          1. 安全和等冪方法
          安全方法——GET和HEAD方法除了補救外不應該有別的采取措施的含義
          等冪方法——沒有副作用的序列是等冪的

          2. OPTIONS——OPTIONS方法代表在請求URI確定的請求/應答過程中通信條件是否可行的信息

          3. GET——GET方法說明了重建信息的內容由請求URI來確定

          4. HEAD——除了應答中禁止返回消息正文外,HEAD方法與GET方法一樣

          5. POST——POST方法實現的實際功能取決于服務器

          6. PUT——PUT方法要求所附實體存儲在提供的請求URI下

          7. DELETE——DELELE方法要求原服務器釋放請求URI指向的資源

          8. TRACE——TRACE方法用于調用遠程的應用層循環請求消息

          9. CONNECT——CONNECT方法用于能動態建立起隧道的代理服務器

          十、 狀態碼定義(status code definitions)

          1. 信息1XX——
          100繼續
          101轉換協議

          2. 成功2XX——
          200請求成功
          201創建
          202接受
          203非權威信息
          204無內容
          205重置內容
          206局部內容

          3. 重新定向3XX——
          300多樣選擇
          301永久移動
          302創立
          303觀察別的部分
          304只讀
          306(沒有用的)
          307臨時重發

          4. 客戶錯誤4xx——
          400壞請求
          401未授權的
          402必需的支付
          403禁用
          404沒有找到
          405不被允許的方法
          406不接受
          407代理服務器認證所必需
          408請求超時
          409沖突
          410停止
          411必需的長度
          412預處理失敗
          413請求實體太大
          414請求的URI過長
          415不被支持的媒體類型
          416請求范圍不滿足
          417期望失敗

          5. 服務器錯誤5xx——
          500服務器內部錯誤
          501不能實現
          502壞網關
          503難以獲得的服務
          504網關超時
          505 HTTP版本不支持

          十一、 訪問驗證(access authentication)——可選擇

          十二、 內容談判(content negotiation)

          HTTP為了"內容談判"提供了一些機制,即當有很多種可能的表示時如何選擇對于一個請求的最佳的表示。

          1. 服務器驅動談判——一個請求的最佳表示的選擇由服務器提供的運算法則來完成

          2. 代理驅動談判——對于一個應答的最佳表示法的選擇是在代理從原服務器端收到最初的應答后實現的

          3. 透明談判——透明的判斷是服務器驅動和代理驅動談判的結合體

          十三、 HTTP中的緩存(caching in HTTP)

          HTTP典型應用于能通過采用緩存技術而提高性能的分布式信息系統

          1. 緩存——
          緩存正確性
          警告信息
          緩存控制機制
          直接的用戶代理警告
          規則和警告的例外情況
          由客戶控制的行為

          2. 過期模型——
          服務器指定模型
          啟發式過期
          年齡計算
          過期計算
          澄清過期值
          澄清多重響應

          3. 確認模型——當緩存器想要用一個失時效的條目來相應客戶的請求,他首先必須向源服務器檢驗這一緩存條目是否仍然可用
          最后修改日期
          標簽緩存確認器
          強弱控制器
          關于何時使用實體標簽和最后修改時間的規則
          不確認條件

          4. 響應的緩存能力——除非被明確限制,緩存系統可以將一成功的響應作為緩存實體一直存儲

          5. 從緩存構造響應——
          端到端和Hop-by-hop報頭
          不可更改報頭
          聯合報頭
          聯合字節范圍

          6. 緩存談判響應

          7. 共享與非共享緩存

          8. 錯誤和不完全響應緩存行為

          9. GET和 HEAD的副作用

          10. 刷新或刪除后的無效性

          11. 強制寫通過

          12. 緩存替換

          13. 歷史紀錄

          十四、 報頭域定義(header field definitions)

          1. Accept——Accept = "Accept" ":" #( media-range [ accept-params ] )
          media-range = ( "*/*"| ( type "/" "*" )| ( type "/" subtype )) *( ";" parameter )
          accept-params = ";" "q" "=" qvalue *( accept-extension )
          accept-extension = ";" token [ "=" ( token | quoted-string ) ]
          例1:Accept: audio/*; q=0.2, audio/basic
          例2:Accept: text/plain; q=0.5, text/html, text/x-dvi; q=0.8, text/x-c

          2. Accept-Charset——Accept-Charset = "Accept-Charset" ":" 1#( ( charset | "*" )[ ";" "q" "=" qvalue ] )
          例:Accept-Charset: iso-8859-5, unicode-1-1;q=0.8

          3. Accept-Encoding——Accept-Encoding = "Accept-Encoding" ":" 1#( codings [ ";" "q" "=" qvalue ] )
          codings = ( content-coding | "*" )
          例:Accept-Encoding: gzip;q=1.0, identity; q=0.5, *;q=0

          4. Accept-Language——Accept-Language = "Accept-Language" ":" 1#( language-range [ ";" "q" "=" qvalue ] )
          language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" )
          例:Accept-Language: da, en-gb;q=0.8, en;q=0.7

          5. Accept-Range——Accept-Ranges = "Accept-Ranges" ":" acceptable-ranges
          acceptable-ranges = 1#range-unit | "none"
          例:Accept-Ranges: bytes

          6. Age——Age = "Age" ":" age-value
          age-value = delta-seconds

          7. Allow——Allow = "Allow" ":" #Method
          例:Allow: GET, HEAD, PUT

          8. Authorization——Authorization = "Authorization" ":" credentials

          9. Cache-Control——Cache-Control = "Cache-Control" ":" 1#cache-directive
          cache-directive = cache-request-directive| cache-response-directive
          cache-request-directive ="no-cache"| "no-store"| "max-age" "=" delta-seconds| "max-stale" [ "=" delta-seconds ]| "min-fresh" "=" delta-seconds| "no-transform"| "only-if-cached"| cache-extension
          cache-response-directive ="public"| "private" [ "=" <"> 1#field-name <"> ]| "no-cache" [ "=" <"> 1#field-name <"> ]| "no-store"| "no-transform"| "must-revalidate"| "proxy-revalidate"| "max-age" "=" delta-seconds| "s-maxage" "=" delta-seconds| cache-extension
          cache-extension = token [ "=" ( token | quoted-string ) ]
          什么是可緩存的
          哪些可能被緩存保存
          對基本過期失效機制的改進
          緩存重新確認有效和重載控制
          不得轉換的指令
          緩存控制擴展

          10. Connection——Connection = "Connection" ":" 1#(connection-token)
          connection-token = token
          例:Connection: close

          11. Content-Encoding——Content-Encoding = "Content-Encoding" ":" 1#content-coding
          例:Content-Encoding: gzip

          12. Content-Language——Content-Language = "Content-Language" ":" 1#language-tag
          例:Content-Language: mi, en

          13. Content-Length——Content-Length = "Content-Length" ":" 1*DIGIT
          Content-Length: 3495

          14. Content-Location——Content-Location = "Content-Location" ":"( absoluteURI | relativeURI )

          15. Content-MD5——Content-MD5 = "Content-MD5" ":" md5-digest
          md5-digest = <base64 of 128 bit MD5 digest as per RFC 1864>

          16. Content-Range——Content-Range = "Content-Range" ":" content-range-spec
          content-range-spec = byte-content-range-spec
          byte-content-range-spec = bytes-unit SP byte-range-resp-spec "/"( instance-length | "*" )
          byte-range-resp-spec = (first-byte-pos "-" last-byte-pos) | "*"
          instance-length = 1*DIGIT
          例:The first 500 bytes:bytes 0-499/1234

          17. Content-Type——Content-Type = "Content-Type" ":" media-type
          例:Content-Type: text/html; charset=ISO-8859-4

          18. Date——Date = "Date" ":" HTTP-date
          例:Date: Tue, 15 Nov 1994 08:12:31 GMT
          沒有時鐘的原服務器的運作

          19. Etag——ETag = "ETag" ":" entity-tag
          例:ETag: W/"xyzzy"

          20. Expect——Expect = "Expect" ":" 1#expectation
          expectation = "100-continue" | expectation-extension
          expectation-extension = token [ "=" ( token | quoted-string )*expect-params ]
          expect-params = ";" token [ "=" ( token | quoted-string ) ]

          21. Expires——Expires = "Expires" ":" HTTP-date
          例:Expires: Thu, 01 Dec 1994 16:00:00 GMT

          22. From——From = "From" ":" mailbox
          例:From: webmaster@w3.org

          23. Host——Host = "Host" ":" host [ ":" port ] ; Section 3.2.2

          24. If-Match——If-Match = "If-Match" ":" ( "*" | 1#entity-tag )
          例:If-Match: "xyzzy", "r2d2xxxx", "c3piozzzz"

          25. If-Modified-Since——If-Modified-Since = "If-Modified-Since" ":" HTTP-date
          例:If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT

          26. If-None-Match ——If-None-Match = "If-None-Match" ":" ( "*" | 1#entity-tag )
          例:If-None-Match: W/"xyzzy", W/"r2d2xxxx", W/"c3piozzzz"

          27. If-Range ——If-Range = "If-Range" ":" ( entity-tag | HTTP-date )

          28. If-Unmodified-Since ——If-Unmodified-Since = "If-Unmodified-Since" ":" HTTP-date
          例:If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT

          29. Last-Modified ——Last-Modified = "Last-Modified" ":" HTTP-date
          例:Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT

          30. Location ——Location = "Location" ":" absoluteURI
          Location: http://www.w3.org/pub/WWW/People.html

          31. Max-Forwards ——Max-Forwards = "Max-Forwards" ":" 1*DIGIT

          32. Pragma ——Pragma = "Pragma" ":" 1#pragma-directive
          pragma-directive = "no-cache" | extension-pragma
          extension-pragma = token [ "=" ( token | quoted-string ) ]

          33. Proxy-Authenticate ——Proxy-Authenticate = "Proxy-Authenticate" ":" 1#challenge

          34. Proxy-Authorization ——Proxy-Authorization = "Proxy-Authorization" ":" credentials

          35. Range——字節范圍
          范圍檢索請求
          Range = "Range" ":" ranges-specifier

          36. Referer——Referer = "Referer" ":" ( absoluteURI | relativeURI )

          37. Retry-After ——Retry-After = "Retry-After" ":" ( HTTP-date | delta-seconds )

          38. Server ——Server = "Server" ":" 1*( product | comment )

          39. TE ——TE = "TE" ":" #( t-codings )
          t-codings = "trailers" | ( transfer-extension [ accept-params ] )
          例:TE: trailers, deflate;q=0.5

          40. Trailer ——Trailer = "Trailer" ":" 1#field-name

          41. Transfer-Encoding ——Transfer-Encoding = "Transfer-Encoding" ":" 1#transfer-coding
          例:Transfer-Encoding: chunked

          42. Upgrade——Upgrade = "Upgrade" ":" 1#product
          例:Upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11

          43. User-Agent ——User-Agent = "User-Agent" ":" 1*( product | comment )
          例:User-Agent: CERN-LineMode/2.15 libwww/2.17b3

          44. Vary ——Vary = "Vary" ":" ( "*" | 1#field-name )

          45. Via ——Via = "Via" ":" 1#( received-protocol received-by [ comment ] )
          received-protocol = [ protocol-name "/" ] protocol-version
          protocol-name = token
          protocol-version = token
          received-by = ( host [ ":" port ] ) | pseudonym
          pseudonym = token
          例:Via: 1.0 ricky, 1.1 ethel, 1.1 fred, 1.0 lucy

          46. Warning = "Warning" ":" 1#warning-value
          warning-value = warn-code SP warn-agent SP warn-text [SP warn-date]
          warn-code = 3DIGIT
          warn-agent = ( host [ ":" port ] ) | pseudonym
          warn-text = quoted-string
          warn-date = <"> HTTP-date <">

          47. WWW-Authenticate ——WWW-Authenticate = "WWW-Authenticate" ":" 1#challenge

          十五、 安全考慮(security considerations)

          一些建議,但是并不包括最終解決方案

          1. 個人信息
          服務器日志信息的濫用
          敏感信息的傳輸
          URI中敏感信息的編碼
          連接到Accept報頭的機要問題

          2. 基于文件和路徑名稱的攻擊

          3. DNS欺騙

          4. Location(位置)報頭和欺騙

          5. 內容傾向問題

          6. 鑒定證書和空閑的客戶機

          7. 代理服務器和高速緩存
          對代理服務器的拒絕服務攻擊

          十六、 感謝

          十七、 參考文獻

          十八、 作者地址

          十九、 附錄


          文章轉自:http://www.cppblog.com/woaidongmao/archive/2008/05/28/51408.html

          posted @ 2009-11-30 23:31 身在半空 閱讀(4635) | 評論 (0)編輯 收藏
          博客開通了,先發表一篇隨筆。
          posted @ 2009-07-27 11:08 身在半空 閱讀(128) | 評論 (0)編輯 收藏
          僅列出標題
          共2頁: 上一頁 1 2 

          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿

          隨筆檔案

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 武定县| 随州市| 商河县| 阳谷县| 泊头市| 连州市| 鄂伦春自治旗| 环江| 体育| 治县。| 茶陵县| 钟山县| 类乌齐县| 锦屏县| 炉霍县| 连平县| 兴国县| 嘉祥县| 香港 | 即墨市| 上饶市| 孙吴县| 太仆寺旗| 昌图县| 黑山县| 宁河县| 陆河县| 无锡市| 江北区| 青冈县| 冕宁县| 阜宁县| 台江县| 繁峙县| 汕尾市| 凤山县| 安龙县| 克拉玛依市| 鹤山市| 镇坪县| 突泉县|