http --- HTTP 模組¶
http 是一個收集了多個用於處理超文本傳輸協定 (HyperText Transfer Protocol) 之模組 (module) 的套件:
http.client是一個低階的 HTTP 協定用戶端;對於高階的 URL 存取請使用urllib.requesthttp.server包含基於socketserver的基本 HTTP 伺服器類別http.cookies包含透過 cookies 實作狀態管理的工具程式 (utilities)http.cookiejar提供了 cookies 的持續留存 (persistence)
The http module also defines the following enums that help you work with http related code:
- class http.HTTPStatus¶
在 3.5 版被加入.
enum.IntEnum的子類別,它定義了一組 HTTP 狀態碼、原理短語 (reason phrase) 以及英文長描述。用法:
>>> 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 狀態碼¶
http.HTTPStatus 當中,已支援並且有於 IANA 註冊的狀態碼有:
狀態碼 |
列舉名稱 |
詳情 |
|---|---|---|
|
|
HTTP Semantics RFC 9110, Section 15.2.1 |
|
|
HTTP Semantics RFC 9110, Section 15.2.2 |
|
|
WebDAV RFC 2518,10.1 節 |
|
|
用於指定提示 (Indicating Hints) RFC 8297 的 HTTP 狀態碼 |
|
|
HTTP Semantics RFC 9110, Section 15.3.1 |
|
|
HTTP Semantics RFC 9110, Section 15.3.2 |
|
|
HTTP Semantics RFC 9110, Section 15.3.3 |
|
|
HTTP Semantics RFC 9110, Section 15.3.4 |
|
|
HTTP Semantics RFC 9110, Section 15.3.5 |
|
|
HTTP Semantics RFC 9110, Section 15.3.6 |
|
|
HTTP Semantics RFC 9110, Section 15.3.7 |
|
|
WebDAV RFC 4918,11.1 節 |
|
|
WebDAV 繫結擴充 (Binding Extensions) RFC 5842,7.1 節(實驗性) |
|
|
HTTP 中的差分編碼 RFC 3229,10.4.1 節 |
|
|
HTTP Semantics RFC 9110, Section 15.4.1 |
|
|
HTTP Semantics RFC 9110, Section 15.4.2 |
|
|
HTTP Semantics RFC 9110, Section 15.4.3 |
|
|
HTTP Semantics RFC 9110, Section 15.4.4 |
|
|
HTTP Semantics RFC 9110, Section 15.4.5 |
|
|
HTTP Semantics RFC 9110, Section 15.4.6 |
|
|
HTTP Semantics RFC 9110, Section 15.4.8 |
|
|
HTTP Semantics RFC 9110, Section 15.4.9 |
|
|
HTTP Semantics RFC 9110, Section 15.5.1 |
|
|
HTTP Semantics RFC 9110, Section 15.5.2 |
|
|
HTTP Semantics RFC 9110, Section 15.5.3 |