Georg Brandl | fe7b00f | 2012-10-06 13:49:34 +0200 | [diff] [blame] | 1 | :mod:`http` --- HTTP modules |
| 2 | ============================ |
| 3 | |
Serhiy Storchaka | e4db769 | 2014-12-23 16:28:28 +0200 | [diff] [blame] | 4 | .. module:: http |
| 5 | :synopsis: HTTP status codes and messages |
| 6 | |
| 7 | .. index:: |
| 8 | pair: HTTP; protocol |
| 9 | single: HTTP; http (standard module) |
| 10 | |
| 11 | **Source code:** :source:`Lib/http/__init__.py` |
| 12 | |
| 13 | :mod:`http` is a also package that collects several modules for working with the |
Georg Brandl | fe7b00f | 2012-10-06 13:49:34 +0200 | [diff] [blame] | 14 | HyperText Transfer Protocol: |
| 15 | |
| 16 | * :mod:`http.client` is a low-level HTTP protocol client; for high-level URL |
| 17 | opening use :mod:`urllib.request` |
| 18 | * :mod:`http.server` contains basic HTTP server classes based on :mod:`socketserver` |
| 19 | * :mod:`http.cookies` has utilities for implementing state management with cookies |
| 20 | * :mod:`http.cookiejar` provides persistence of cookies |
Serhiy Storchaka | e4db769 | 2014-12-23 16:28:28 +0200 | [diff] [blame] | 21 | |
| 22 | :mod:`http` is also a module that defines a number of HTTP status codes and |
| 23 | associated messages through the :class:`http.HTTPStatus` enum: |
| 24 | |
| 25 | .. class:: HTTPStatus |
| 26 | |
Berker Peksag | be6a5da | 2014-12-25 14:14:09 +0200 | [diff] [blame^] | 27 | .. versionadded:: 3.5 |
| 28 | |
Serhiy Storchaka | e4db769 | 2014-12-23 16:28:28 +0200 | [diff] [blame] | 29 | A subclass of :class:`enum.IntEnum` that defines a set of HTTP status codes, |
| 30 | reason phrases and long descriptions written in English. |
| 31 | |
| 32 | Usage:: |
| 33 | |
| 34 | >>> from http import HTTPStatus |
| 35 | >>> HTTPStatus.OK |
| 36 | <HTTPStatus.OK: 200> |
| 37 | >>> HTTPStatus.OK == 200 |
| 38 | True |
| 39 | >>> http.HTTPStatus.OK.value |
| 40 | 200 |
| 41 | >>> HTTPStatus.OK.phrase |
| 42 | 'OK' |
| 43 | >>> HTTPStatus.OK.description |
| 44 | 'Request fulfilled, document follows' |
| 45 | >>> list(HTTPStatus) |
| 46 | [<HTTPStatus.CONTINUE: 100>, <HTTPStatus.SWITCHING_PROTOCOLS: 101>, ...] |
| 47 | |
Serhiy Storchaka | e4db769 | 2014-12-23 16:28:28 +0200 | [diff] [blame] | 48 | The supported HTTP status codes are: |
| 49 | |
| 50 | === ============================== |
| 51 | 100 Continue |
| 52 | 101 Switching Protocols |
| 53 | 102 Processing |
| 54 | 200 OK |
| 55 | 201 Created |
| 56 | 202 Accepted |
| 57 | 203 Non-Authoritative Information |
| 58 | 204 No Content |
| 59 | 205 Reset Content |
| 60 | 206 Partial Content |
| 61 | 207 Multi-Status |
| 62 | 208 Already Reported |
| 63 | 226 IM Used |
| 64 | 300 Multiple Choices |
| 65 | 301 Moved Permanently |
| 66 | 302 Found |
| 67 | 303 See Other |
| 68 | 304 Not Modified |
| 69 | 305 Use Proxy |
| 70 | 306 Switch Proxy |
| 71 | 307 Temporary Redirect |
| 72 | 308 Permanent Redirect |
| 73 | 400 Bad Request |
| 74 | 401 Unauthorized |
| 75 | 402 Payment Required |
| 76 | 403 Forbidden |
| 77 | 404 Not Found |
| 78 | 405 Method Not Allowed |
| 79 | 406 Not Acceptable |
| 80 | 407 Proxy Authentication Required |
| 81 | 408 Request Timeout |
| 82 | 409 Conflict |
| 83 | 410 Gone |
| 84 | 411 Length Required |
| 85 | 412 Precondition Failed |
| 86 | 413 Request Entity Too Large |
| 87 | 414 Request URI Too Long |
| 88 | 415 Unsupported Media Type |
| 89 | 416 Request Range Not Satisfiable |
| 90 | 417 Expectation Failed |
| 91 | 418 I'm a teapot |
| 92 | 419 Authentication Timeout |
| 93 | 420 Method Failure *(Spring framework)* |
| 94 | 422 Unprocessable Entity |
| 95 | 423 Locked |
| 96 | 424 Failed Dependency |
| 97 | 426 Upgrade Required |
| 98 | 428 Precondition Required |
| 99 | 429 Too Many Requests |
| 100 | 431 Request Header Field Too Large |
| 101 | 440 Login Timeout *(Microsoft)* |
| 102 | 444 No Response *(Nginx)* |
| 103 | 449 Retry With *(Microsoft)* |
| 104 | 450 Blocked By Windows Parental Controls *(Microsoft)* |
| 105 | 494 Request Header Too Large *(Nginx)* |
| 106 | 495 Cert Error *(Nginx)* |
| 107 | 496 No Cert *(Nginx)* |
| 108 | 497 HTTP To HTTPS *(Nginx)* |
| 109 | 499 Client Closed Request *(Nginx)* |
| 110 | 500 Internal Server Error |
| 111 | 501 Not Implemented |
| 112 | 502 Bad Gateway |
| 113 | 503 Service Unavailable |
| 114 | 504 Gateway Timeout |
| 115 | 505 HTTP Version Not Supported |
| 116 | 506 Variant Also Negotiates |
| 117 | 507 Insufficient Storage |
| 118 | 508 Loop Detected |
| 119 | 509 Bandwidth Limit Exceeded |
| 120 | 510 Not Extended |
| 121 | 511 Network Authentication Required |
| 122 | 520 Origin Error *(CloudFlare)* |
| 123 | 521 Web Server Is Down *(CloudFlare)* |
| 124 | 522 Connection Timed Out *(CloudFlare)* |
| 125 | 523 Proxy Declined Request *(CloudFlare)* |
| 126 | 524 A Timeout Occurred *(CloudFlare)* |
| 127 | 598 Network Read Timeout Error |
| 128 | 599 Network Connect Timeout Error |
| 129 | === ============================== |