http
— HTTP 模块
¶
源代码: Lib/http/__init__.py
http
is a package that collects several modules for working with the HyperText Transfer Protocol:
http.client
is a low-level HTTP protocol client; for high-level URL opening use
urllib.request
http.server
contains basic HTTP server classes based on
socketserver
http.cookies
has utilities for implementing state management with cookies
http.cookiejar
提供 Cookie 的持久性
http
is also a module that defines a number of HTTP status codes and associated messages through the
http.HTTPStatus
枚举:
http.
HTTPStatus
¶
3.5 版新增。
子类化的
enum.IntEnum
that defines a set of HTTP status codes, reason phrases and long descriptions written in English.
用法:
>>> 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>, ...]
支持,
IANA-registered
状态码可用于
http.HTTPStatus
是:
|
Code |
枚举名称 |
细节 |
|---|---|---|
|
|
|
HTTP/1.1 RFC 7231 ,章节 6.2.1 |
|
|
|
HTTP/1.1 RFC 7231 ,章节 6.2.2 |
|
|
|
WebDAV RFC 2518 ,章节 10.1 |
|
|
|
HTTP 状态码用于指示提示 RFC 8297 |
|
|
|
HTTP/1.1 RFC 7231 ,章节 6.3.1 |
|
|
|
HTTP/1.1 RFC 7231 ,章节 6.3.2 |
|
|
|
HTTP/1.1 RFC 7231 ,章节 6.3.3 |
|
|
|
HTTP/1.1 RFC 7231 ,章节 6.3.4 |
|
|
|
HTTP/1.1 RFC 7231 ,章节 6.3.5 |
|
|
|
HTTP/1.1 RFC 7231 ,章节 6.3.6 |
|
|
|
HTTP/1.1 RFC 7233 ,章节 4.1 |
|
|
|
WebDAV RFC 4918 ,章节 11.1 |
|
|
|
WebDAV 绑定扩展 RFC 5842 ,章节 7.1 (实验性) |
|
|
|
增量编码在 HTTP RFC 3229 ,章节 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 ,章节 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 |
|
|
|
HTCPCP/1.0 RFC 2324 , Section 2.3.2 |
|
|
|
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 |
|
|
|
Using Early Data in HTTP RFC 8470 |
|
|
|
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 |
|
|
|
An HTTP Status Code to Report Legal Obstacles RFC 7725 |
|
|
|
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 ,章节 6.6.6 |
|
|
|
Transparent Content Negotiation in HTTP RFC 2295 , Section 8.1 (Experimental) |
|
|
|
WebDAV RFC 4918 , Section 11.5 |
|
|
|
WebDAV 绑定扩展 RFC 5842 , Section 7.2 (Experimental) |
|
|
|
An HTTP Extension Framework RFC 2774 , Section 7 (Experimental) |
|
|
|
Additional HTTP Status Codes RFC 6585 ,章节 6 |
In order to preserve backwards compatibility, enum values are also present in the
http.client
module in the form of constants. The enum name is equal to the constant name (i.e.
http.HTTPStatus.OK
is also available as
http.client.OK
).
3.7 版改变:
添加
421 MISDIRECTED_REQUEST
状态码。
3.8 版新增:
添加
451 UNAVAILABLE_FOR_LEGAL_REASONS
状态码。
3.9 版新增:
添加
103 EARLY_HINTS
,
418 IM_A_TEAPOT
and
425 TOO_EARLY
状态码。