rmaake1 / httpstatuses

A directory of HTTP Status Codes and code references
https://httpstatuses.com
MIT License
592 stars 77 forks source link

Add Python status constants #57

Closed WALL-E closed 8 years ago

WALL-E commented 8 years ago

Add Python status constants, a total of 41, include [200, 201, 202, 203, 204, 205, 206, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 100, 101, 300, 301, 302, 303, 304, 305, 306, 307, 500, 501, 502, 503, 504, 505]

shrink commented 8 years ago

Thank you very much for the contribution!

I'm not familiar with Python, as I understand it version 3 was released a few years ago but a lot of developers continue with version 2, and version 2 and 3 are different in a number of ways. From my brief browse of the Python documentation it appears that as of Python 3.5 there is a different approach to http status codes:

>>> from http import HTTPStatus
>>> HTTPStatus.OK
<HTTPStatus.OK: 200>
>>> HTTPStatus.OK == 200
True
>>> http.HTTPStatus.OK.value
200
>>> HTTPStatus.OK.phrase
'OK'
>>> HTTPStatus.OK.description
'Request fulfilled, document follows'
>>> list(HTTPStatus)
[<HTTPStatus.CONTINUE: 100>, <HTTPStatus.SWITCHING_PROTOCOLS: 101>, ...]

via https://docs.python.org/3/library/http.html#http.HTTPStatus

Are the status constants you have included for Python 2, or everything prior to Python 3.5? I think that it might be worth changing Python HTTP Status Constant to Python 2 HTTP Status Constant for clarity if it's the case that these are for Python 2, or you might have a better idea? Additionally it might be helpful to add the new Python 3.5 approach, so that all Python developers are covered.

Please let me know if my understanding is correct.

Thanks again for taking the time to contribute these :)

WALL-E commented 8 years ago

You are right. I forgot about python3, I'll fix it right away.

The httplib module has been renamed to http.client in Python 3.

http.HTTPStatus[New in version 3.5.]