21.11.http — HTTP modules¶
Source code:Lib/http/__init__.py
http is a package that collects several modules for working with theHyperText Transfer Protocol:
http.clientis a low-level HTTP protocol client; for high-level URLopening useurllib.requesthttp.servercontains basic HTTP server classes based onsocketserverhttp.cookieshas utilities for implementing state management with cookieshttp.cookiejarprovides persistence of cookies
http is also a module that defines a number of HTTP status codes andassociated messages through thehttp.HTTPStatus enum:
- class
http.HTTPStatus¶ New in version 3.5.
A subclass of
enum.IntEnumthat defines a set of HTTP status codes,reason phrases and long descriptions written in English.Usage:
>>>fromhttpimportHTTPStatus>>>HTTPStatus.OK<HTTPStatus.OK: 200>>>>HTTPStatus.OK==200True>>>http.HTTPStatus.OK.value200>>>HTTPStatus.OK.phrase'OK'>>>HTTPStatus.OK.description'Request fulfilled, document follows'>>>list(HTTPStatus)[<HTTPStatus.CONTINUE: 100>, <HTTPStatus.SWITCHING_PROTOCOLS: 101>, ...]
21.11.1.HTTP status codes¶
Supported,IANA-registeredstatus codes available inhttp.HTTPStatus are:
Code | Enum Name | Details |
|---|---|---|
|
| HTTP/1.1RFC 7231, Section 6.2.1 |
|
| HTTP/1.1RFC 7231, Section 6.2.2 |
|
| WebDAVRFC 2518, Section 10.1 |
|
| HTTP/1.1RFC 7231, Section 6.3.1 |
|
| HTTP/1.1RFC 7231, Section 6.3.2 |
|
| HTTP/1.1RFC 7231, Section 6.3.3 |
|
| HTTP/1.1RFC 7231, Section 6.3.4 |
|
| HTTP/1.1RFC 7231, Section 6.3.5 |
|
| HTTP/1.1RFC 7231, Section 6.3.6 |
|
| HTTP/1.1RFC 7233, Section 4.1 |
|
| WebDAVRFC 4918, Section 11.1 |
|
| WebDAV Binding ExtensionsRFC 5842, Section 7.1 (Experimental) |
|
| Delta Encoding in HTTPRFC 3229, Section 10.4.1 |
|
| HTTP/1.1RFC 7231, Section 6.4.1 |
|
| HTTP/1.1RFC 7231, Section 6.4.2 |
|
| HTTP/1.1RFC 7231, Section 6.4.3 |
|
| HTTP/1.1RFC 7231, Section 6.4.4 |
|
| HTTP/1.1RFC 7232, Section 4.1 |
|
| HTTP/1.1RFC 7231, Section 6.4.5 |
|
| HTTP/1.1RFC 7231, Section 6.4.7 |
|
| Permanent RedirectRFC 7238, Section 3 (Experimental) |
|
| HTTP/1.1RFC 7231, Section 6.5.1 |
|
| HTTP/1.1 AuthenticationRFC 7235, Section 3.1 |
|
| HTTP/1.1RFC 7231, Section 6.5.2 |
|
| HTTP/1.1RFC 7231, Section 6.5.3 |
|
| HTTP/1.1RFC 7231, Section 6.5.4 |
|
| HTTP/1.1RFC 7231, Section 6.5.5 |
|
| HTTP/1.1RFC 7231, Section 6.5.6 |
|
| HTTP/1.1 AuthenticationRFC 7235, Section 3.2 |
|
| HTTP/1.1RFC 7231, Section 6.5.7 |
|
| HTTP/1.1RFC 7231, Section 6.5.8 |
|
| HTTP/1.1RFC 7231, Section 6.5.9 |
|
| HTTP/1.1RFC 7231, Section 6.5.10 |
|
| HTTP/1.1RFC 7232, Section 4.2 |
|
| HTTP/1.1RFC 7231, Section 6.5.11 |
|
| HTTP/1.1RFC 7231, Section 6.5.12 |
|
| HTTP/1.1RFC 7231, Section 6.5.13 |
|
| HTTP/1.1 Range RequestsRFC 7233, Section 4.4 |
|
| HTTP/1.1RFC 7231, Section 6.5.14 |
|
| WebDAVRFC 4918, Section 11.2 |
|
| WebDAVRFC 4918, Section 11.3 |
|
| WebDAVRFC 4918, Section 11.4 |
|
| HTTP/1.1RFC 7231, Section 6.5.15 |
|
| Additional HTTP Status CodesRFC 6585 |
|
| Additional HTTP Status CodesRFC 6585 |
|
| Additional HTTP Status CodesRFC 6585 |
|
| HTTP/1.1RFC 7231, Section 6.6.1 |
|
| HTTP/1.1RFC 7231, Section 6.6.2 |
|
| HTTP/1.1RFC 7231, Section 6.6.3 |
|
| HTTP/1.1RFC 7231, Section 6.6.4 |
|
| HTTP/1.1RFC 7231, Section 6.6.5 |
|
| HTTP/1.1RFC 7231, Section 6.6.6 |
|
| Transparent Content Negotiation in HTTPRFC 2295, Section 8.1 (Experimental) |
|
| WebDAVRFC 4918, Section 11.5 |
|
| WebDAV Binding ExtensionsRFC 5842, Section 7.2 (Experimental) |
|
| An HTTP Extension FrameworkRFC 2774, Section 7 (Experimental) |
|
| Additional HTTP Status CodesRFC 6585, Section 6 |
In order to preserve backwards compatibility, enum values are also presentin thehttp.client module in the form of constants. The enum name isequal to the constant name (i.e.http.HTTPStatus.OK is also available ashttp.client.OK).
