http --- HTTP 模塊?
源代碼: Lib/http/__init__.py
http 是一個(gè)包,它收集了多個(gè)用于處理超文本傳輸協(xié)議的模塊:
http.client是一個(gè)低層級(jí)的 HTTP 協(xié)議客戶端;對(duì)于高層級(jí)的 URL 訪問請(qǐng)使用urllib.requesthttp.server包含基于socketserver的基本 HTTP 服務(wù)類http.cookies包含一些有用來(lái)實(shí)現(xiàn)通過(guò) cookies 進(jìn)行狀態(tài)管理的工具http.cookiejar提供了 cookies 的持久化
http 也是一個(gè)通過(guò) http.HTTPStatus 枚舉定義了一些 HTTP 狀態(tài)碼以及相關(guān)聯(lián)消息的模塊
-
class
http.HTTPStatus? 3.5 新版功能.
enum.IntEnum的子類,它定義了組 HTTP 狀態(tài)碼,原理短語(yǔ)以及用英語(yǔ)書寫的長(zhǎng)描述文本。用法:
>>> from http import HTTPStatus >>> HTTPStatus.OK <HTTPStatus.OK: 200> >>> HTTPStatus.OK == 200 True >>> HTTPStatus.OK.value 200 >>> HTTPStatus.OK.phrase 'OK' >>> HTTPStatus.OK.description 'Request fulfilled, document follows' >>> list(HTTPStatus) [<HTTPStatus.CONTINUE: 100>, <HTTPStatus.SWITCHING_PROTOCOLS: 101>, ...]
HTTP 狀態(tài)碼?
已支持并且已在 http.HTTPStatus IANA 注冊(cè) 的狀態(tài)碼有:
雙字母代碼 |
映射名 |
詳情 |
|---|---|---|
|
|
HTTP/1.1 RFC 7231, Section 6.2.1 |
|
|
HTTP/1.1 RFC 7231, Section 6.2.2 |
|
|
WebDAV RFC 2518, Section 10.1 |
|
|
HTTP/1.1 RFC 7231, Section 6.3.1 |
|
|
HTTP/1.1 RFC 7231, Section 6.3.2 |
|
|
HTTP/1.1 RFC 7231, Section 6.3.3 |
|
|
HTTP/1.1 RFC 7231, Section 6.3.4 |
|
|
HTTP/1.1 RFC 7231, Section 6.3.5 |
|
|
HTTP/1.1 RFC 7231, Section 6.3.6 |
|
|
HTTP/1.1 RFC 7233, Section 4.1 |
|
|
WebDAV RFC 4918, Section 11.1 |
|
|
WebDAV Binding Extensions RFC 5842, Section 7.1 (Experimental) |
|
|
Delta Encoding in HTTP RFC 3229, Section 10.4.1 |
|
|
HTTP/1.1 RFC 7231, Section 6.4.1 |
|
|
HTTP/1.1 RFC 7231, Section 6.4.2 |
|
|
HTTP/1.1 RFC 7231, Section 6.4.3 |
|
|
HTTP/1.1 RFC 7231, Section 6.4.4 |
|
|
HTTP/1.1 RFC 7232, Section 4.1 |
|
|
HTTP/1.1 RFC 7231, Section 6.4.5 |
|
|
HTTP/1.1 RFC 7231, Section 6.4.7 |
|
|
Permanent Redirect RFC 7238, Section 3 (Experimental) |
|
|
HTTP/1.1 RFC 7231, Section 6.5.1 |
|
|
HTTP/1.1 Authentication RFC 7235, Section 3.1 |
|
|
HTTP/1.1 RFC 7231, Section 6.5.2 |
|
|
HTTP/1.1 RFC 7231, Section 6.5.3 |
|
|
HTTP/1.1 RFC 7231, Section 6.5.4 |
|
|
HTTP/1.1 RFC 7231, Section 6.5.5 |
|
|
HTTP/1.1 RFC 7231, Section 6.5.6 |
|
|
HTTP/1.1 Authentication RFC 7235, Section 3.2 |
|
|
HTTP/1.1 RFC 7231, Section 6.5.7 |
|
|
HTTP/1.1 RFC 7231, Section 6.5.8 |
|
|
HTTP/1.1 RFC 7231, Section 6.5.9 |
|
|
HTTP/1.1 RFC 7231, Section 6.5.10 |
|
|
HTTP/1.1 RFC 7232, Section 4.2 |
|
|
HTTP/1.1 RFC 7231, Section 6.5.11 |
|
|
HTTP/1.1 RFC 7231, Section 6.5.12 |
|
|
HTTP/1.1 RFC 7231, Section 6.5.13 |
|
|
HTTP/1.1 Range Requests RFC 7233, Section 4.4 |
|
|
HTTP/1.1 RFC 7231, Section 6.5.14 |
|
|
HTTP/2 RFC 7540, Section 9.1.2 |
|
|
WebDAV RFC 4918, Section 11.2 |
|
|
WebDAV RFC 4918, Section 11.3 |
|
|
WebDAV RFC 4918, Section 11.4 |
|
|
HTTP/1.1 RFC 7231, Section 6.5.15 |
|
|
Additional HTTP Status Codes RFC 6585 |
|
|
Additional HTTP Status Codes RFC 6585 |
|
|
Additional HTTP Status Codes RFC 6585 |
|
|
HTTP/1.1 RFC 7231, Section 6.6.1 |
|
|
HTTP/1.1 RFC 7231, Section 6.6.2 |
|
|
HTTP/1.1 RFC 7231, Section 6.6.3 |
|
|
HTTP/1.1 RFC 7231, Section 6.6.4 |
|
|
HTTP/1.1 RFC 7231, Section 6.6.5 |
|
|
HTTP/1.1 RFC 7231, Section 6.6.6 |
|
|
透明內(nèi)容協(xié)商在: HTTP RFC 2295, Section 8.1 (實(shí)驗(yàn)性的) |
|
|
WebDAV RFC 4918, Section 11.5 |
|
|
WebDAV Binding Extensions RFC 5842, Section 7.2 (Experimental) |
|
|
An HTTP Extension Framework RFC 2774, Section 7 (Experimental) |
|
|
Additional HTTP Status Codes RFC 6585, Section 6 |
為了保持向后兼容性,枚舉值也以常量形式出現(xiàn)在 http.client 模塊中,。 枚舉名等于常量名 (例如 http.HTTPStatus.OK 也可以是 http.client.OK)。
在 3.7 版更改: 添加了 421 MISDIRECTED_REQUEST 狀態(tài)碼。
