1 | n/a | from enum import IntEnum |
---|
2 | n/a | |
---|
3 | n/a | __all__ = ['HTTPStatus'] |
---|
4 | n/a | |
---|
5 | n/a | class HTTPStatus(IntEnum): |
---|
6 | n/a | """HTTP status codes and reason phrases |
---|
7 | n/a | |
---|
8 | n/a | Status codes from the following RFCs are all observed: |
---|
9 | n/a | |
---|
10 | n/a | * RFC 7231: Hypertext Transfer Protocol (HTTP/1.1), obsoletes 2616 |
---|
11 | n/a | * RFC 6585: Additional HTTP Status Codes |
---|
12 | n/a | * RFC 3229: Delta encoding in HTTP |
---|
13 | n/a | * RFC 4918: HTTP Extensions for WebDAV, obsoletes 2518 |
---|
14 | n/a | * RFC 5842: Binding Extensions to WebDAV |
---|
15 | n/a | * RFC 7238: Permanent Redirect |
---|
16 | n/a | * RFC 2295: Transparent Content Negotiation in HTTP |
---|
17 | n/a | * RFC 2774: An HTTP Extension Framework |
---|
18 | n/a | """ |
---|
19 | n/a | def __new__(cls, value, phrase, description=''): |
---|
20 | n/a | obj = int.__new__(cls, value) |
---|
21 | n/a | obj._value_ = value |
---|
22 | n/a | |
---|
23 | n/a | obj.phrase = phrase |
---|
24 | n/a | obj.description = description |
---|
25 | n/a | return obj |
---|
26 | n/a | |
---|
27 | n/a | # informational |
---|
28 | n/a | CONTINUE = 100, 'Continue', 'Request received, please continue' |
---|
29 | n/a | SWITCHING_PROTOCOLS = (101, 'Switching Protocols', |
---|
30 | n/a | 'Switching to new protocol; obey Upgrade header') |
---|
31 | n/a | PROCESSING = 102, 'Processing' |
---|
32 | n/a | |
---|
33 | n/a | # success |
---|
34 | n/a | OK = 200, 'OK', 'Request fulfilled, document follows' |
---|
35 | n/a | CREATED = 201, 'Created', 'Document created, URL follows' |
---|
36 | n/a | ACCEPTED = (202, 'Accepted', |
---|
37 | n/a | 'Request accepted, processing continues off-line') |
---|
38 | n/a | NON_AUTHORITATIVE_INFORMATION = (203, |
---|
39 | n/a | 'Non-Authoritative Information', 'Request fulfilled from cache') |
---|
40 | n/a | NO_CONTENT = 204, 'No Content', 'Request fulfilled, nothing follows' |
---|
41 | n/a | RESET_CONTENT = 205, 'Reset Content', 'Clear input form for further input' |
---|
42 | n/a | PARTIAL_CONTENT = 206, 'Partial Content', 'Partial content follows' |
---|
43 | n/a | MULTI_STATUS = 207, 'Multi-Status' |
---|
44 | n/a | ALREADY_REPORTED = 208, 'Already Reported' |
---|
45 | n/a | IM_USED = 226, 'IM Used' |
---|
46 | n/a | |
---|
47 | n/a | # redirection |
---|
48 | n/a | MULTIPLE_CHOICES = (300, 'Multiple Choices', |
---|
49 | n/a | 'Object has several resources -- see URI list') |
---|
50 | n/a | MOVED_PERMANENTLY = (301, 'Moved Permanently', |
---|
51 | n/a | 'Object moved permanently -- see URI list') |
---|
52 | n/a | FOUND = 302, 'Found', 'Object moved temporarily -- see URI list' |
---|
53 | n/a | SEE_OTHER = 303, 'See Other', 'Object moved -- see Method and URL list' |
---|
54 | n/a | NOT_MODIFIED = (304, 'Not Modified', |
---|
55 | n/a | 'Document has not changed since given time') |
---|
56 | n/a | USE_PROXY = (305, 'Use Proxy', |
---|
57 | n/a | 'You must use proxy specified in Location to access this resource') |
---|
58 | n/a | TEMPORARY_REDIRECT = (307, 'Temporary Redirect', |
---|
59 | n/a | 'Object moved temporarily -- see URI list') |
---|
60 | n/a | PERMANENT_REDIRECT = (308, 'Permanent Redirect', |
---|
61 | n/a | 'Object moved temporarily -- see URI list') |
---|
62 | n/a | |
---|
63 | n/a | # client error |
---|
64 | n/a | BAD_REQUEST = (400, 'Bad Request', |
---|
65 | n/a | 'Bad request syntax or unsupported method') |
---|
66 | n/a | UNAUTHORIZED = (401, 'Unauthorized', |
---|
67 | n/a | 'No permission -- see authorization schemes') |
---|
68 | n/a | PAYMENT_REQUIRED = (402, 'Payment Required', |
---|
69 | n/a | 'No payment -- see charging schemes') |
---|
70 | n/a | FORBIDDEN = (403, 'Forbidden', |
---|
71 | n/a | 'Request forbidden -- authorization will not help') |
---|
72 | n/a | NOT_FOUND = (404, 'Not Found', |
---|
73 | n/a | 'Nothing matches the given URI') |
---|
74 | n/a | METHOD_NOT_ALLOWED = (405, 'Method Not Allowed', |
---|
75 | n/a | 'Specified method is invalid for this resource') |
---|
76 | n/a | NOT_ACCEPTABLE = (406, 'Not Acceptable', |
---|
77 | n/a | 'URI not available in preferred format') |
---|
78 | n/a | PROXY_AUTHENTICATION_REQUIRED = (407, |
---|
79 | n/a | 'Proxy Authentication Required', |
---|
80 | n/a | 'You must authenticate with this proxy before proceeding') |
---|
81 | n/a | REQUEST_TIMEOUT = (408, 'Request Timeout', |
---|
82 | n/a | 'Request timed out; try again later') |
---|
83 | n/a | CONFLICT = 409, 'Conflict', 'Request conflict' |
---|
84 | n/a | GONE = (410, 'Gone', |
---|
85 | n/a | 'URI no longer exists and has been permanently removed') |
---|
86 | n/a | LENGTH_REQUIRED = (411, 'Length Required', |
---|
87 | n/a | 'Client must specify Content-Length') |
---|
88 | n/a | PRECONDITION_FAILED = (412, 'Precondition Failed', |
---|
89 | n/a | 'Precondition in headers is false') |
---|
90 | n/a | REQUEST_ENTITY_TOO_LARGE = (413, 'Request Entity Too Large', |
---|
91 | n/a | 'Entity is too large') |
---|
92 | n/a | REQUEST_URI_TOO_LONG = (414, 'Request-URI Too Long', |
---|
93 | n/a | 'URI is too long') |
---|
94 | n/a | UNSUPPORTED_MEDIA_TYPE = (415, 'Unsupported Media Type', |
---|
95 | n/a | 'Entity body in unsupported format') |
---|
96 | n/a | REQUESTED_RANGE_NOT_SATISFIABLE = (416, |
---|
97 | n/a | 'Requested Range Not Satisfiable', |
---|
98 | n/a | 'Cannot satisfy request range') |
---|
99 | n/a | EXPECTATION_FAILED = (417, 'Expectation Failed', |
---|
100 | n/a | 'Expect condition could not be satisfied') |
---|
101 | n/a | UNPROCESSABLE_ENTITY = 422, 'Unprocessable Entity' |
---|
102 | n/a | LOCKED = 423, 'Locked' |
---|
103 | n/a | FAILED_DEPENDENCY = 424, 'Failed Dependency' |
---|
104 | n/a | UPGRADE_REQUIRED = 426, 'Upgrade Required' |
---|
105 | n/a | PRECONDITION_REQUIRED = (428, 'Precondition Required', |
---|
106 | n/a | 'The origin server requires the request to be conditional') |
---|
107 | n/a | TOO_MANY_REQUESTS = (429, 'Too Many Requests', |
---|
108 | n/a | 'The user has sent too many requests in ' |
---|
109 | n/a | 'a given amount of time ("rate limiting")') |
---|
110 | n/a | REQUEST_HEADER_FIELDS_TOO_LARGE = (431, |
---|
111 | n/a | 'Request Header Fields Too Large', |
---|
112 | n/a | 'The server is unwilling to process the request because its header ' |
---|
113 | n/a | 'fields are too large') |
---|
114 | n/a | |
---|
115 | n/a | # server errors |
---|
116 | n/a | INTERNAL_SERVER_ERROR = (500, 'Internal Server Error', |
---|
117 | n/a | 'Server got itself in trouble') |
---|
118 | n/a | NOT_IMPLEMENTED = (501, 'Not Implemented', |
---|
119 | n/a | 'Server does not support this operation') |
---|
120 | n/a | BAD_GATEWAY = (502, 'Bad Gateway', |
---|
121 | n/a | 'Invalid responses from another server/proxy') |
---|
122 | n/a | SERVICE_UNAVAILABLE = (503, 'Service Unavailable', |
---|
123 | n/a | 'The server cannot process the request due to a high load') |
---|
124 | n/a | GATEWAY_TIMEOUT = (504, 'Gateway Timeout', |
---|
125 | n/a | 'The gateway server did not receive a timely response') |
---|
126 | n/a | HTTP_VERSION_NOT_SUPPORTED = (505, 'HTTP Version Not Supported', |
---|
127 | n/a | 'Cannot fulfill request') |
---|
128 | n/a | VARIANT_ALSO_NEGOTIATES = 506, 'Variant Also Negotiates' |
---|
129 | n/a | INSUFFICIENT_STORAGE = 507, 'Insufficient Storage' |
---|
130 | n/a | LOOP_DETECTED = 508, 'Loop Detected' |
---|
131 | n/a | NOT_EXTENDED = 510, 'Not Extended' |
---|
132 | n/a | NETWORK_AUTHENTICATION_REQUIRED = (511, |
---|
133 | n/a | 'Network Authentication Required', |
---|
134 | n/a | 'The client needs to authenticate to gain network access') |
---|