@@ -19,7 +19,8 @@ class HTTPStatus(IntEnum):
1919 * RFC 2295: Transparent Content Negotiation in HTTP
2020 * RFC 2774: An HTTP Extension Framework
2121 """
22- def __new__ (cls , value , phrase , description = '' ):
22+
23+ def __new__ (cls , value , phrase , description = "" ):
2324 obj = int .__new__ (cls , value )
2425 obj ._value_ = value
2526
@@ -31,110 +32,154 @@ def __str__(self):
3132 return str (self .value )
3233
3334 # informational
34- CONTINUE = 100 , 'Continue' , 'Request received, please continue'
35- SWITCHING_PROTOCOLS = (101 , 'Switching Protocols' ,
36- 'Switching to new protocol; obey Upgrade header' )
37- PROCESSING = 102 , 'Processing'
35+ CONTINUE = 100 , "Continue" , "Request received, please continue"
36+ SWITCHING_PROTOCOLS = (
37+ 101 ,
38+ "Switching Protocols" ,
39+ "Switching to new protocol; obey Upgrade header" ,
40+ )
41+ PROCESSING = 102 , "Processing"
3842
3943 # success
40- OK = 200 , 'OK' , 'Request fulfilled, document follows'
41- CREATED = 201 , 'Created' , 'Document created, URL follows'
42- ACCEPTED = (202 , 'Accepted' ,
43- 'Request accepted, processing continues off-line' )
44- NON_AUTHORITATIVE_INFORMATION = (203 ,
45- 'Non-Authoritative Information' , 'Request fulfilled from cache' )
46- NO_CONTENT = 204 , 'No Content' , 'Request fulfilled, nothing follows'
47- RESET_CONTENT = 205 , 'Reset Content' , 'Clear input form for further input'
48- PARTIAL_CONTENT = 206 , 'Partial Content' , 'Partial content follows'
49- MULTI_STATUS = 207 , 'Multi-Status'
50- ALREADY_REPORTED = 208 , 'Already Reported'
51- IM_USED = 226 , 'IM Used'
44+ OK = 200 , "OK" , "Request fulfilled, document follows"
45+ CREATED = 201 , "Created" , "Document created, URL follows"
46+ ACCEPTED = (202 , "Accepted" , "Request accepted, processing continues off-line" )
47+ NON_AUTHORITATIVE_INFORMATION = (
48+ 203 ,
49+ "Non-Authoritative Information" ,
50+ "Request fulfilled from cache" ,
51+ )
52+ NO_CONTENT = 204 , "No Content" , "Request fulfilled, nothing follows"
53+ RESET_CONTENT = 205 , "Reset Content" , "Clear input form for further input"
54+ PARTIAL_CONTENT = 206 , "Partial Content" , "Partial content follows"
55+ MULTI_STATUS = 207 , "Multi-Status"
56+ ALREADY_REPORTED = 208 , "Already Reported"
57+ IM_USED = 226 , "IM Used"
5258
5359 # redirection
54- MULTIPLE_CHOICES = (300 , 'Multiple Choices' ,
55- 'Object has several resources -- see URI list' )
56- MOVED_PERMANENTLY = (301 , 'Moved Permanently' ,
57- 'Object moved permanently -- see URI list' )
58- FOUND = 302 , 'Found' , 'Object moved temporarily -- see URI list'
59- SEE_OTHER = 303 , 'See Other' , 'Object moved -- see Method and URL list'
60- NOT_MODIFIED = (304 , 'Not Modified' ,
61- 'Document has not changed since given time' )
62- USE_PROXY = (305 , 'Use Proxy' ,
63- 'You must use proxy specified in Location to access this resource' )
64- TEMPORARY_REDIRECT = (307 , 'Temporary Redirect' ,
65- 'Object moved temporarily -- see URI list' )
66- PERMANENT_REDIRECT = (308 , 'Permanent Redirect' ,
67- 'Object moved temporarily -- see URI list' )
60+ MULTIPLE_CHOICES = (
61+ 300 ,
62+ "Multiple Choices" ,
63+ "Object has several resources -- see URI list" ,
64+ )
65+ MOVED_PERMANENTLY = (
66+ 301 ,
67+ "Moved Permanently" ,
68+ "Object moved permanently -- see URI list" ,
69+ )
70+ FOUND = 302 , "Found" , "Object moved temporarily -- see URI list"
71+ SEE_OTHER = 303 , "See Other" , "Object moved -- see Method and URL list"
72+ NOT_MODIFIED = (304 , "Not Modified" , "Document has not changed since given time" )
73+ USE_PROXY = (
74+ 305 ,
75+ "Use Proxy" ,
76+ "You must use proxy specified in Location to access this resource" ,
77+ )
78+ TEMPORARY_REDIRECT = (
79+ 307 ,
80+ "Temporary Redirect" ,
81+ "Object moved temporarily -- see URI list" ,
82+ )
83+ PERMANENT_REDIRECT = (
84+ 308 ,
85+ "Permanent Redirect" ,
86+ "Object moved temporarily -- see URI list" ,
87+ )
6888
6989 # client error
70- BAD_REQUEST = (400 , 'Bad Request' ,
71- 'Bad request syntax or unsupported method' )
72- UNAUTHORIZED = (401 , 'Unauthorized' ,
73- 'No permission -- see authorization schemes' )
74- PAYMENT_REQUIRED = (402 , 'Payment Required' ,
75- 'No payment -- see charging schemes' )
76- FORBIDDEN = (403 , 'Forbidden' ,
77- 'Request forbidden -- authorization will not help' )
78- NOT_FOUND = (404 , 'Not Found' ,
79- 'Nothing matches the given URI' )
80- METHOD_NOT_ALLOWED = (405 , 'Method Not Allowed' ,
81- 'Specified method is invalid for this resource' )
82- NOT_ACCEPTABLE = (406 , 'Not Acceptable' ,
83- 'URI not available in preferred format' )
84- PROXY_AUTHENTICATION_REQUIRED = (407 ,
85- 'Proxy Authentication Required' ,
86- 'You must authenticate with this proxy before proceeding' )
87- REQUEST_TIMEOUT = (408 , 'Request Timeout' ,
88- 'Request timed out; try again later' )
89- CONFLICT = 409 , 'Conflict' , 'Request conflict'
90- GONE = (410 , 'Gone' ,
91- 'URI no longer exists and has been permanently removed' )
92- LENGTH_REQUIRED = (411 , 'Length Required' ,
93- 'Client must specify Content-Length' )
94- PRECONDITION_FAILED = (412 , 'Precondition Failed' ,
95- 'Precondition in headers is false' )
96- REQUEST_ENTITY_TOO_LARGE = (413 , 'Request Entity Too Large' ,
97- 'Entity is too large' )
98- REQUEST_URI_TOO_LONG = (414 , 'Request-URI Too Long' ,
99- 'URI is too long' )
100- UNSUPPORTED_MEDIA_TYPE = (415 , 'Unsupported Media Type' ,
101- 'Entity body in unsupported format' )
102- REQUESTED_RANGE_NOT_SATISFIABLE = (416 ,
103- 'Requested Range Not Satisfiable' ,
104- 'Cannot satisfy request range' )
105- EXPECTATION_FAILED = (417 , 'Expectation Failed' ,
106- 'Expect condition could not be satisfied' )
107- UNPROCESSABLE_ENTITY = 422 , 'Unprocessable Entity'
108- LOCKED = 423 , 'Locked'
109- FAILED_DEPENDENCY = 424 , 'Failed Dependency'
110- UPGRADE_REQUIRED = 426 , 'Upgrade Required'
111- PRECONDITION_REQUIRED = (428 , 'Precondition Required' ,
112- 'The origin server requires the request to be conditional' )
113- TOO_MANY_REQUESTS = (429 , 'Too Many Requests' ,
114- 'The user has sent too many requests in '
115- 'a given amount of time ("rate limiting")' )
116- REQUEST_HEADER_FIELDS_TOO_LARGE = (431 ,
117- 'Request Header Fields Too Large' ,
118- 'The server is unwilling to process the request because its header '
119- 'fields are too large' )
90+ BAD_REQUEST = (400 , "Bad Request" , "Bad request syntax or unsupported method" )
91+ UNAUTHORIZED = (401 , "Unauthorized" , "No permission -- see authorization schemes" )
92+ PAYMENT_REQUIRED = (402 , "Payment Required" , "No payment -- see charging schemes" )
93+ FORBIDDEN = (403 , "Forbidden" , "Request forbidden -- authorization will not help" )
94+ NOT_FOUND = (404 , "Not Found" , "Nothing matches the given URI" )
95+ METHOD_NOT_ALLOWED = (
96+ 405 ,
97+ "Method Not Allowed" ,
98+ "Specified method is invalid for this resource" ,
99+ )
100+ NOT_ACCEPTABLE = (406 , "Not Acceptable" , "URI not available in preferred format" )
101+ PROXY_AUTHENTICATION_REQUIRED = (
102+ 407 ,
103+ "Proxy Authentication Required" ,
104+ "You must authenticate with this proxy before proceeding" ,
105+ )
106+ REQUEST_TIMEOUT = (408 , "Request Timeout" , "Request timed out; try again later" )
107+ CONFLICT = 409 , "Conflict" , "Request conflict"
108+ GONE = (410 , "Gone" , "URI no longer exists and has been permanently removed" )
109+ LENGTH_REQUIRED = (411 , "Length Required" , "Client must specify Content-Length" )
110+ PRECONDITION_FAILED = (
111+ 412 ,
112+ "Precondition Failed" ,
113+ "Precondition in headers is false" ,
114+ )
115+ REQUEST_ENTITY_TOO_LARGE = (413 , "Request Entity Too Large" , "Entity is too large" )
116+ REQUEST_URI_TOO_LONG = (414 , "Request-URI Too Long" , "URI is too long" )
117+ UNSUPPORTED_MEDIA_TYPE = (
118+ 415 ,
119+ "Unsupported Media Type" ,
120+ "Entity body in unsupported format" ,
121+ )
122+ REQUESTED_RANGE_NOT_SATISFIABLE = (
123+ 416 ,
124+ "Requested Range Not Satisfiable" ,
125+ "Cannot satisfy request range" ,
126+ )
127+ EXPECTATION_FAILED = (
128+ 417 ,
129+ "Expectation Failed" ,
130+ "Expect condition could not be satisfied" ,
131+ )
132+ UNPROCESSABLE_ENTITY = 422 , "Unprocessable Entity"
133+ LOCKED = 423 , "Locked"
134+ FAILED_DEPENDENCY = 424 , "Failed Dependency"
135+ UPGRADE_REQUIRED = 426 , "Upgrade Required"
136+ PRECONDITION_REQUIRED = (
137+ 428 ,
138+ "Precondition Required" ,
139+ "The origin server requires the request to be conditional" ,
140+ )
141+ TOO_MANY_REQUESTS = (
142+ 429 ,
143+ "Too Many Requests" ,
144+ "The user has sent too many requests in "
145+ 'a given amount of time ("rate limiting")' ,
146+ )
147+ REQUEST_HEADER_FIELDS_TOO_LARGE = (
148+ 431 ,
149+ "Request Header Fields Too Large" ,
150+ "The server is unwilling to process the request because its header "
151+ "fields are too large" ,
152+ )
120153
121154 # server errors
122- INTERNAL_SERVER_ERROR = (500 , 'Internal Server Error' ,
123- 'Server got itself in trouble' )
124- NOT_IMPLEMENTED = (501 , 'Not Implemented' ,
125- 'Server does not support this operation' )
126- BAD_GATEWAY = (502 , 'Bad Gateway' ,
127- 'Invalid responses from another server/proxy' )
128- SERVICE_UNAVAILABLE = (503 , 'Service Unavailable' ,
129- 'The server cannot process the request due to a high load' )
130- GATEWAY_TIMEOUT = (504 , 'Gateway Timeout' ,
131- 'The gateway server did not receive a timely response' )
132- HTTP_VERSION_NOT_SUPPORTED = (505 , 'HTTP Version Not Supported' ,
133- 'Cannot fulfill request' )
134- VARIANT_ALSO_NEGOTIATES = 506 , 'Variant Also Negotiates'
135- INSUFFICIENT_STORAGE = 507 , 'Insufficient Storage'
136- LOOP_DETECTED = 508 , 'Loop Detected'
137- NOT_EXTENDED = 510 , 'Not Extended'
138- NETWORK_AUTHENTICATION_REQUIRED = (511 ,
139- 'Network Authentication Required' ,
140- 'The client needs to authenticate to gain network access' )
155+ INTERNAL_SERVER_ERROR = (
156+ 500 ,
157+ "Internal Server Error" ,
158+ "Server got itself in trouble" ,
159+ )
160+ NOT_IMPLEMENTED = (501 , "Not Implemented" , "Server does not support this operation" )
161+ BAD_GATEWAY = (502 , "Bad Gateway" , "Invalid responses from another server/proxy" )
162+ SERVICE_UNAVAILABLE = (
163+ 503 ,
164+ "Service Unavailable" ,
165+ "The server cannot process the request due to a high load" ,
166+ )
167+ GATEWAY_TIMEOUT = (
168+ 504 ,
169+ "Gateway Timeout" ,
170+ "The gateway server did not receive a timely response" ,
171+ )
172+ HTTP_VERSION_NOT_SUPPORTED = (
173+ 505 ,
174+ "HTTP Version Not Supported" ,
175+ "Cannot fulfill request" ,
176+ )
177+ VARIANT_ALSO_NEGOTIATES = 506 , "Variant Also Negotiates"
178+ INSUFFICIENT_STORAGE = 507 , "Insufficient Storage"
179+ LOOP_DETECTED = 508 , "Loop Detected"
180+ NOT_EXTENDED = 510 , "Not Extended"
181+ NETWORK_AUTHENTICATION_REQUIRED = (
182+ 511 ,
183+ "Network Authentication Required" ,
184+ "The client needs to authenticate to gain network access" ,
185+ )
0 commit comments