請求頭
\r\n\r\n請求體
php
響應頭
\r\n\r\n響應體
html
瀏覽器支持的內容python
重要的交互參數web
其餘參數django
Header | 解釋 | 示例 |
---|---|---|
Accept-Ranges | 代表服務器是否支持指定範圍請求及哪一種類型的分段請求 | Accept-Ranges: bytes |
Age | 從原始服務器到代理緩存造成的估算時間(以秒計,非負) | Age: 12 |
Allow | 對某網絡資源的有效的請求行爲,不容許則返回405 | Allow: GET, HEAD |
Cache-Control | 告訴全部的緩存機制是否能夠緩存及哪一種類型 | Cache-Control: no-cache |
Content-Encoding | web服務器支持的返回內容壓縮編碼類型。 | Content-Encoding: gzip |
Content-Language | 響應體的語言 | Content-Language: en,zh |
Content-Length | 響應體的長度 | Content-Length: 348 |
Content-Location | 請求資源可替代的備用的另外一地址 | Content-Location: /index.htm |
Content-MD5 | 返回資源的MD5校驗值 | Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ== |
Content-Range | 在整個返回體中本部分的字節位置 | Content-Range: bytes 21010-47021/47022 |
Content-Type | 返回內容的MIME類型 | Content-Type: text/html; charset=utf-8 |
Date | 原始服務器消息發出的時間 | Date: Tue, 15 Nov 2010 08:12:31 GMT |
ETag | 請求變量的實體標籤的當前值 | ETag: 「737060cd8c284d8af7ad3082f209582d」 |
Expires | 響應過時的日期和時間 | Expires: Thu, 01 Dec 2010 16:00:00 GMT |
Last-Modified | 請求資源的最後修改時間 | Last-Modified: Tue, 15 Nov 2010 12:45:26 GMT |
Location | 用來重定向接收方到非請求URL的位置來完成請求或標識新的資源 | Location: http://www.zcmhi.com/archives/94.html |
Pragma | 包括實現特定的指令,它可應用到響應鏈上的任何接收方 | Pragma: no-cache |
Proxy-Authenticate | 它指出認證方案和可應用到代理的該URL上的參數 | Proxy-Authenticate: Basic |
refresh | 應用於重定向或一個新的資源被創造,在5秒以後重定向(由網景提出,被大部分瀏覽器支持) | Refresh: 5; url=http://www.atool.org/httptest.php |
Retry-After | 若是實體暫時不可取,通知客戶端在指定時間以後再次嘗試 | Retry-After: 120 |
Server | web服務器軟件名稱 | Server: Apache/1.3.27 (Unix) (Red-Hat/Linux) |
Set-Cookie | 設置Http Cookie | Set-Cookie: UserID=JohnDoe; Max-Age=3600; Version=1 |
Trailer | 指出頭域在分塊傳輸編碼的尾部存在 | Trailer: Max-Forwards |
Transfer-Encoding | 文件傳輸編碼 | Transfer-Encoding:chunked |
Vary | 告訴下游代理是使用緩存響應仍是從原始服務器請求 | Vary: * |
Via | 告知代理客戶端響應是經過哪裏發送的 | Via: 1.0 fred, 1.1 nowhere.com (Apache/1.1) |
Warning | 警告實體可能存在的問題 | Warning: 199 Miscellaneous warning |
WWW-Authenticate | 代表客戶端請求實體應該使用的受權方案 | WWW-Authenticate: Basic |
X-Powered-By | 由語言解析器或者應用程序框架輸出的,這個值的意義用於告知網站是用何種語言或框架編寫的 | X-Powered-By: ASP.NET |
版本協議
+響應碼
+附加信息
\r\n\r\n響應體
編程
如:HTTP/1.1 200 OK\r\n\r\n響應體
flask
響應碼瀏覽器
經常使用響應碼緩存
按照上述步驟進行分類能夠分紅三類服務器
import socket import re server = socket.socket() server.bind(('127.0.0.1',8080)) server.listen(5) while True: conn,adder = server.accept() a = conn.recv(8888) data = str(a,encoding='utf8') print(data) conn.send(bytes('HTTP/1.1 200 OK\r\n\r\n',encoding='utf8')) conn.send(bytes('ywy',encoding='utf8'))