HTTP 協議基礎

HTTP 協議報文格式

圖片來自 HTTP協議淺析(中):請求報文和響應報文

  • 請求報文
http_request.jpg
  • 響應報文
http_response.png

HTTP Satus Code

3xx Redirection

  • 304: NOT MODIFIED
    A conditional GET or HEAD request has been received and would have resulted in a 200 OK response if it were not for the fact that the condition evaluated to false.

4xx: Client Error

  • 401: UNAUTHORIZED
    The request has not been applied because it lacks valid authentication credentials for the target resource.

  • 404: NOT FOUND
    The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

  • 405: METHOD NOT ALLOWED
    The method received in the request-line is known by the origin server but not supported by the target resource. (對于請求所標識的資源,不允許使用請求行中所指定的方法。)

  • 407: PROXY AUTHENTICATION REQUIRED
    Similar to 401 Unauthorized, but it indicates that the client needs to authenticate itself in order to use a proxy.

HTTP Methods

POST

HTTP headers

Etag

Etag(Entity tag) 具體解釋: 什么是ETag

Tornado/1.1 web.py 源碼:

            if (self._status_code == 200 and self.request.method == "GET" and
                "Etag" not in self._headers):
                hasher = hashlib.sha1()
                for part in self._write_buffer:
                    hasher.update(part)
                etag = '"%s"' % hasher.hexdigest()
                inm = self.request.headers.get("If-None-Match")
                if inm and inm.find(etag) != -1:
                    self._write_buffer = []
                    self.set_status(304)
                else:
                    self.set_header("Etag", etag)

location

跳轉(重定向)
當瀏覽器接受到頭信息中的 Location: xxxx 后,就會自動跳轉到 xxxx 指向的URL地址.
例如,

header["location"] =  "http://www.baidu.com/"

keep-alive

具體閱讀: HTTP Keep-Alive是什么?如何工作?

keep-alive

read more

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 本文整理自MIN飛翔博客 [1] 1. 概念 協議是指計算機通信網絡中兩臺計算機之間進行通信所必須共同遵守的規定或...
    HoyaWhite閱讀 2,705評論 2 20
  • 概述 HTTP協議全稱為超文本傳輸協議(HyperText Transfer Protocol),它使得網絡上的W...
    WeberLisper閱讀 1,140評論 1 1
  • HTTP協議 HTTP協議作為網絡傳輸的基本協議,有著廣泛的應用。 HTTP協議的完整內容很多,但是其核心知識卻又...
    小甲魚python閱讀 381評論 0 1
  • HTTP的定義 Http(HyperText Transfer Protocol,超文本傳輸協議),是用于從萬維網...
    不思則亡閱讀 492評論 0 1
  • 我現在就開始期待冬天了,嘿嘿! 畫完好幾天的雪人今天可以出來見見人啦! 大家好,我還在繪畫的康莊大道上,荊棘前行!
    anMoo韓魔閱讀 306評論 4 6