httpcode icon indicating copy to clipboard operation
httpcode copied to clipboard

Get codes, phrases and descriptions dynamically instead of hard-coding

Open MestreLion opened this issue 4 years ago • 0 comments

Considering this:

# Codes with messages are taken verbatim from BaseHTTPServer.py

# Table mapping response codes to messages; entries have the
# form {code: (shortmessage, longmessage)}.
# See RFC 2616.
STATUS_CODES = {
    100: ('Continue', 'Request received, please continue'),

Why the trouble to hardcode it?

import http
STATUS_CODES = {sc.value: (sc.phrase, sc.description) for sc in http.HTTPStatus}

MestreLion avatar Jun 05 '22 11:06 MestreLion