Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing description for codes in http.HTTPStatus #127089

Open
donBarbos opened this issue Nov 21, 2024 · 5 comments
Open

Add missing description for codes in http.HTTPStatus #127089

donBarbos opened this issue Nov 21, 2024 · 5 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@donBarbos
Copy link

donBarbos commented Nov 21, 2024

Bug report

Bug description:

We have Enum of 62 HTTP status codes. They stores in http.HTTPStatus class and 14 of them don't have description field.
I think it is not-obvious behavior when calling the description field, one code returns text and another returns an empty string:

import http
assert http.HTTPStatus.PROCESSING.description == ''
assert http.HTTPStatus.OK.description == 'Request fulfilled, document follows'

Path file: ./Lib/http/__init__.py
List of codes with empty description:

    PROCESSING = 102, 'Processing'
    EARLY_HINTS = 103, 'Early Hints'
    MULTI_STATUS = 207, 'Multi-Status'
    ALREADY_REPORTED = 208, 'Already Reported'
    IM_USED = 226, 'IM Used'
    UNPROCESSABLE_CONTENT = 422, 'Unprocessable Content'
    LOCKED = 423, 'Locked'
    FAILED_DEPENDENCY = 424, 'Failed Dependency'
    TOO_EARLY = 425, 'Too Early'
    UPGRADE_REQUIRED = 426, 'Upgrade Required'
    VARIANT_ALSO_NEGOTIATES = 506, 'Variant Also Negotiates'
    INSUFFICIENT_STORAGE = 507, 'Insufficient Storage'
    LOOP_DETECTED = 508, 'Loop Detected'
    NOT_EXTENDED = 510, 'Not Extended'

I am ready to send PR

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

@donBarbos donBarbos added the type-bug An unexpected behavior, bug, or error label Nov 21, 2024
@skirpichev skirpichev added the stdlib Python modules in the Lib dir label Nov 21, 2024
@picnixz
Copy link
Contributor

picnixz commented Nov 21, 2024

I think it's good for completeness but is it possible for the strings to match the RFC if any?

@donBarbos
Copy link
Author

I have not seen such RFC and I think that the description was created by the developers. but I can try to search for the necessary RFCs and if I don't find them I will inform you

@picnixz
Copy link
Contributor

picnixz commented Nov 21, 2024

IIRC those codes are described in rfc2616 (and other rfcs that supersede that one, but those specific rfcs can be found on that one). If there is no short description, let's just use their name.

@donBarbos
Copy link
Author

donBarbos commented Nov 21, 2024

I didn't find any mentions of the description in the RFCs that were specified in this file (there are only phrases):

class HTTPStatus:
"""HTTP status codes and reason phrases
Status codes from the following RFCs are all observed:
* RFC 9110: HTTP Semantics, obsoletes 7231, which obsoleted 2616
* RFC 6585: Additional HTTP Status Codes
* RFC 3229: Delta encoding in HTTP
* RFC 4918: HTTP Extensions for WebDAV, obsoletes 2518
* RFC 5842: Binding Extensions to WebDAV
* RFC 7238: Permanent Redirect
* RFC 2295: Transparent Content Negotiation in HTTP
* RFC 2774: An HTTP Extension Framework
* RFC 7725: An HTTP Status Code to Report Legal Obstacles
* RFC 7540: Hypertext Transfer Protocol Version 2 (HTTP/2)
* RFC 2324: Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0)
* RFC 8297: An HTTP Status Code for Indicating Hints
* RFC 8470: Using Early Data in HTTP
"""

I found only commit which was made in 2014 and where the description field was added. But there are no explanations:
e4db769#diff-7b8ddb05aa75662657f99bf3fcd7778a8f3b37083edafe2c274d42edf6ea05f5R28

@donBarbos
Copy link
Author

@picnixz could you take a look at my PR #127100?, i was not sure that i need to add Misc/NEWS.d/... file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants