Skip to content

Commit 71de839

Browse files
donBarbosethanfurmanasvetlov
authored
gh-127089: Add missing description for codes in http.HTTPStatus (#127100)
Co-authored-by: Ethan Furman <ethan@stoneleaf.us> Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
1 parent 0b5f1fa commit 71de839

File tree

2 files changed

+52
-30
lines changed

2 files changed

+52
-30
lines changed

Diff for: Lib/http/__init__.py

+26-15
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ def is_server_error(self):
5454
CONTINUE = 100, 'Continue', 'Request received, please continue'
5555
SWITCHING_PROTOCOLS = (101, 'Switching Protocols',
5656
'Switching to new protocol; obey Upgrade header')
57-
PROCESSING = 102, 'Processing'
58-
EARLY_HINTS = 103, 'Early Hints'
57+
PROCESSING = 102, 'Processing', 'Server is processing the request'
58+
EARLY_HINTS = (103, 'Early Hints',
59+
'Headers sent to prepare for the response')
5960

6061
# success
6162
OK = 200, 'OK', 'Request fulfilled, document follows'
@@ -67,9 +68,11 @@ def is_server_error(self):
6768
NO_CONTENT = 204, 'No Content', 'Request fulfilled, nothing follows'
6869
RESET_CONTENT = 205, 'Reset Content', 'Clear input form for further input'
6970
PARTIAL_CONTENT = 206, 'Partial Content', 'Partial content follows'
70-
MULTI_STATUS = 207, 'Multi-Status'
71-
ALREADY_REPORTED = 208, 'Already Reported'
72-
IM_USED = 226, 'IM Used'
71+
MULTI_STATUS = (207, 'Multi-Status',
72+
'Response contains multiple statuses in the body')
73+
ALREADY_REPORTED = (208, 'Already Reported',
74+
'Operation has already been reported')
75+
IM_USED = 226, 'IM Used', 'Request completed using instance manipulations'
7376

7477
# redirection
7578
MULTIPLE_CHOICES = (300, 'Multiple Choices',
@@ -128,15 +131,19 @@ def is_server_error(self):
128131
EXPECTATION_FAILED = (417, 'Expectation Failed',
129132
'Expect condition could not be satisfied')
130133
IM_A_TEAPOT = (418, 'I\'m a Teapot',
131-
'Server refuses to brew coffee because it is a teapot.')
134+
'Server refuses to brew coffee because it is a teapot')
132135
MISDIRECTED_REQUEST = (421, 'Misdirected Request',
133136
'Server is not able to produce a response')
134-
UNPROCESSABLE_CONTENT = 422, 'Unprocessable Content'
137+
UNPROCESSABLE_CONTENT = (422, 'Unprocessable Content',
138+
'Server is not able to process the contained instructions')
135139
UNPROCESSABLE_ENTITY = UNPROCESSABLE_CONTENT
136-
LOCKED = 423, 'Locked'
137-
FAILED_DEPENDENCY = 424, 'Failed Dependency'
138-
TOO_EARLY = 425, 'Too Early'
139-
UPGRADE_REQUIRED = 426, 'Upgrade Required'
140+
LOCKED = 423, 'Locked', 'Resource of a method is locked'
141+
FAILED_DEPENDENCY = (424, 'Failed Dependency',
142+
'Dependent action of the request failed')
143+
TOO_EARLY = (425, 'Too Early',
144+
'Server refuses to process a request that might be replayed')
145+
UPGRADE_REQUIRED = (426, 'Upgrade Required',
146+
'Server refuses to perform the request using the current protocol')
140147
PRECONDITION_REQUIRED = (428, 'Precondition Required',
141148
'The origin server requires the request to be conditional')
142149
TOO_MANY_REQUESTS = (429, 'Too Many Requests',
@@ -164,10 +171,14 @@ def is_server_error(self):
164171
'The gateway server did not receive a timely response')
165172
HTTP_VERSION_NOT_SUPPORTED = (505, 'HTTP Version Not Supported',
166173
'Cannot fulfill request')
167-
VARIANT_ALSO_NEGOTIATES = 506, 'Variant Also Negotiates'
168-
INSUFFICIENT_STORAGE = 507, 'Insufficient Storage'
169-
LOOP_DETECTED = 508, 'Loop Detected'
170-
NOT_EXTENDED = 510, 'Not Extended'
174+
VARIANT_ALSO_NEGOTIATES = (506, 'Variant Also Negotiates',
175+
'Server has an internal configuration error')
176+
INSUFFICIENT_STORAGE = (507, 'Insufficient Storage',
177+
'Server is not able to store the representation')
178+
LOOP_DETECTED = (508, 'Loop Detected',
179+
'Server encountered an infinite loop while processing a request')
180+
NOT_EXTENDED = (510, 'Not Extended',
181+
'Request does not meet the resource access policy')
171182
NETWORK_AUTHENTICATION_REQUIRED = (511,
172183
'Network Authentication Required',
173184
'The client needs to authenticate to gain network access')

Diff for: Lib/test/test_httplib.py

+26-15
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,9 @@ def is_server_error(self):
594594
CONTINUE = 100, 'Continue', 'Request received, please continue'
595595
SWITCHING_PROTOCOLS = (101, 'Switching Protocols',
596596
'Switching to new protocol; obey Upgrade header')
597-
PROCESSING = 102, 'Processing'
598-
EARLY_HINTS = 103, 'Early Hints'
597+
PROCESSING = 102, 'Processing', 'Server is processing the request'
598+
EARLY_HINTS = (103, 'Early Hints',
599+
'Headers sent to prepare for the response')
599600
# success
600601
OK = 200, 'OK', 'Request fulfilled, document follows'
601602
CREATED = 201, 'Created', 'Document created, URL follows'
@@ -606,9 +607,11 @@ def is_server_error(self):
606607
NO_CONTENT = 204, 'No Content', 'Request fulfilled, nothing follows'
607608
RESET_CONTENT = 205, 'Reset Content', 'Clear input form for further input'
608609
PARTIAL_CONTENT = 206, 'Partial Content', 'Partial content follows'
609-
MULTI_STATUS = 207, 'Multi-Status'
610-
ALREADY_REPORTED = 208, 'Already Reported'
611-
IM_USED = 226, 'IM Used'
610+
MULTI_STATUS = (207, 'Multi-Status',
611+
'Response contains multiple statuses in the body')
612+
ALREADY_REPORTED = (208, 'Already Reported',
613+
'Operation has already been reported')
614+
IM_USED = 226, 'IM Used', 'Request completed using instance manipulations'
612615
# redirection
613616
MULTIPLE_CHOICES = (300, 'Multiple Choices',
614617
'Object has several resources -- see URI list')
@@ -665,15 +668,19 @@ def is_server_error(self):
665668
EXPECTATION_FAILED = (417, 'Expectation Failed',
666669
'Expect condition could not be satisfied')
667670
IM_A_TEAPOT = (418, 'I\'m a Teapot',
668-
'Server refuses to brew coffee because it is a teapot.')
671+
'Server refuses to brew coffee because it is a teapot')
669672
MISDIRECTED_REQUEST = (421, 'Misdirected Request',
670673
'Server is not able to produce a response')
671-
UNPROCESSABLE_CONTENT = 422, 'Unprocessable Content'
674+
UNPROCESSABLE_CONTENT = (422, 'Unprocessable Content',
675+
'Server is not able to process the contained instructions')
672676
UNPROCESSABLE_ENTITY = UNPROCESSABLE_CONTENT
673-
LOCKED = 423, 'Locked'
674-
FAILED_DEPENDENCY = 424, 'Failed Dependency'
675-
TOO_EARLY = 425, 'Too Early'
676-
UPGRADE_REQUIRED = 426, 'Upgrade Required'
677+
LOCKED = 423, 'Locked', 'Resource of a method is locked'
678+
FAILED_DEPENDENCY = (424, 'Failed Dependency',
679+
'Dependent action of the request failed')
680+
TOO_EARLY = (425, 'Too Early',
681+
'Server refuses to process a request that might be replayed')
682+
UPGRADE_REQUIRED = (426, 'Upgrade Required',
683+
'Server refuses to perform the request using the current protocol')
677684
PRECONDITION_REQUIRED = (428, 'Precondition Required',
678685
'The origin server requires the request to be conditional')
679686
TOO_MANY_REQUESTS = (429, 'Too Many Requests',
@@ -700,10 +707,14 @@ def is_server_error(self):
700707
'The gateway server did not receive a timely response')
701708
HTTP_VERSION_NOT_SUPPORTED = (505, 'HTTP Version Not Supported',
702709
'Cannot fulfill request')
703-
VARIANT_ALSO_NEGOTIATES = 506, 'Variant Also Negotiates'
704-
INSUFFICIENT_STORAGE = 507, 'Insufficient Storage'
705-
LOOP_DETECTED = 508, 'Loop Detected'
706-
NOT_EXTENDED = 510, 'Not Extended'
710+
VARIANT_ALSO_NEGOTIATES = (506, 'Variant Also Negotiates',
711+
'Server has an internal configuration error')
712+
INSUFFICIENT_STORAGE = (507, 'Insufficient Storage',
713+
'Server is not able to store the representation')
714+
LOOP_DETECTED = (508, 'Loop Detected',
715+
'Server encountered an infinite loop while processing a request')
716+
NOT_EXTENDED = (510, 'Not Extended',
717+
'Request does not meet the resource access policy')
707718
NETWORK_AUTHENTICATION_REQUIRED = (511,
708719
'Network Authentication Required',
709720
'The client needs to authenticate to gain network access')

0 commit comments

Comments
 (0)