http
--- HTTP 模塊?
源代碼: Lib/http/__init__.py
http
是一個(gè)包,它收集了多個(gè)用于處理超文本傳輸協(xié)議的模塊:
http.client
是一個(gè)低層級(jí)的 HTTP 協(xié)議客戶端;對(duì)于高層級(jí)的 URL 訪問請(qǐng)使用urllib.request
http.server
包含基于socketserver
的基本 HTTP 服務(wù)類http.cookies
包含一些有用來實(shí)現(xiàn)通過 cookies 進(jìn)行狀態(tài)管理的工具http.cookiejar
提供了 cookies 的持久化
The http
module also defines the following enums that help you work with http related code:
- class http.HTTPStatus?
3.5 新版功能.
enum.IntEnum
的子類,它定義了組 HTTP 狀態(tài)碼,原理短語以及用英語書寫的長(zhǎng)描述文本。用法:
>>> from http import HTTPStatus >>> HTTPStatus.OK HTTPStatus.OK >>> HTTPStatus.OK == 200 True >>> HTTPStatus.OK.value 200 >>> HTTPStatus.OK.phrase 'OK' >>> HTTPStatus.OK.description 'Request fulfilled, document follows' >>> list(HTTPStatus) [HTTPStatus.CONTINUE, HTTPStatus.SWITCHING_PROTOCOLS, ...]
HTTP 狀態(tài)碼?
Supported,
IANA-registered status codes
available in http.HTTPStatus
are:
雙字母代碼 |
映射名 |
詳情 |
---|---|---|
|
|
HTTP/1.1 RFC 7231, 6.2.1 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.2.2 節(jié) |
|
|
WebDAV RFC 2518, 10.1 節(jié) |
|
|
用于指定提示 RFC 8297 的 HTTP 狀態(tài)碼 |
|
|
HTTP/1.1 RFC 7231, 6.3.1 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.3.2 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.3.3 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.3.4 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.3.5 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.3.6 節(jié) |
|
|
HTTP/1.1 RFC 7233, 4.1 節(jié) |
|
|
WebDAV RFC 4918, 11.1 節(jié) |
|
|
WebDAV Binding Extensions RFC 5842, 7.1 節(jié)(實(shí)驗(yàn)性) |
|
|
Delta Encoding in HTTP RFC 3229, 10.4.1 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.4.1 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.4.2 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.4.3 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.4.4 節(jié) |
|
|
HTTP/1.1 RFC 7232, 4.1 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.4.5 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.4.7 節(jié) |
|
|
Permanent Redirect RFC 7238, Section 3 (Experimental) |
|
|
HTTP/1.1 RFC 7231, 6.5.1 節(jié) |
|
|
HTTP/1.1 Authentication RFC 7235, 3.1 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.5.2 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.5.3 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.5.4 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.5.5 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.5.6 節(jié) |
|
|
HTTP/1.1 Authentication RFC 7235, 3.1 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.5.7 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.5.8 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.5.9 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.5.10 節(jié) |
|
|
HTTP/1.1 RFC 7232, 4.2 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.5.11 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.5.12 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.5.13 節(jié) |
|
|
HTTP/1.1 Range Requests RFC 7233, 4.4 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.5.14 節(jié) |
|
|
HTCPCP/1.0 RFC 2324, Section 2.3.2 |
|
|
HTTP/2 RFC 7540, 9.1.2 節(jié) |
|
|
WebDAV RFC 4918, 11.2 節(jié) |
|
|
WebDAV RFC 4918, 11.3 節(jié) |
|
|
WebDAV RFC 4918, 11.4 節(jié) |
|
|
使用 HTTP RFC 8470 中的早期數(shù)據(jù) |
|
|
HTTP/1.1 RFC 7231, 6.5.15 節(jié) |
|
|
Additional HTTP Status Codes RFC 6585 |
|
|
Additional HTTP Status Codes RFC 6585 |
|
|
Additional HTTP Status Codes RFC 6585 |
|
|
HTTP 狀態(tài)碼用于報(bào)告法律障礙 RFC 7725 |
|
|
HTTP/1.1 RFC 7231, 6.6.1 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.6.2 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.6.3 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.6.4 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.6.5 節(jié) |
|
|
HTTP/1.1 RFC 7231, 6.6.6 節(jié) |
|
|
透明內(nèi)容協(xié)商在: HTTP RFC 2295, 8.1 節(jié)(實(shí)驗(yàn)性) |
|
|
WebDAV RFC 4918, 11.5 節(jié) |
|
|
WebDAV Binding Extensions RFC 5842, 7.2 節(jié)(實(shí)驗(yàn)性) |
|
|
WebDAV Binding Extensions RFC 5842, 7.2 節(jié)(實(shí)驗(yàn)性) |
|
|
Additional HTTP Status Codes RFC 6585, 6 節(jié) |
為了保持向后兼容性,枚舉值也以常量形式出現(xiàn)在 http.client
模塊中,。 枚舉名等于常量名 (例如 http.HTTPStatus.OK
也可以是 http.client.OK
)。
在 3.7 版更改: 添加了 421 MISDIRECTED_REQUEST
狀態(tài)碼。
3.8 新版功能: 添加了 451 UNAVAILABLE_FOR_LEGAL_REASONS
狀態(tài)碼。
3.9 新版功能: 增加了 103 EARLY_HINTS
, 418 IM_A_TEAPOT
和 425 TOO_EARLY
狀態(tài)碼
- class http.HTTPMethod?
3.11 新版功能.
A subclass of
enum.StrEnum
that defines a set of HTTP methods and descriptions written in English.用法:
>>> from http import HTTPMethod >>> HTTMethod.GET HTTMethod.GET >>> HTTMethod.GET == 'GET' True >>> HTTMethod.GET.value 'GET' >>> HTTMethod.GET.description 'Transfer a current representation of the target resource.' >>> list(HTTPMethod) [HTTPMethod.GET, HTTPMethod.HEAD, ...]
HTTP methods?
Supported,
IANA-registered methods
available in http.HTTPMethod
are:
Method |
映射名 |
詳情 |
---|---|---|
|
|
HTTP/1.1 RFC 7231, Section 4.3.1 |
|
|
HTTP/1.1 RFC 7231, Section 4.3.2 |
|
|
HTTP/1.1 RFC 7231, Section 4.3.3 |
|
|
HTTP/1.1 RFC 7231, Section 4.3.4 |
|
|
HTTP/1.1 RFC 7231, Section 4.3.5 |
|
|
HTTP/1.1 RFC 7231, Section 4.3.6 |
|
|
HTTP/1.1 RFC 7231, Section 4.3.7 |
|
|
HTTP/1.1 RFC 7231, Section 4.3.8 |
|
|
HTTP/1.1 RFC 5789 |