Python HTTP Modules- http.HTTPStatus














































Python HTTP Modules- http.HTTPStatus



class http.HTTPStatus

This class is infact a subclass of enum.IntEnum that defines and includes set of HTTP status codes. Along with codes, it also describes long descriptions and reason phrases in English.

To understand further how this class works and is used, let us go through the example code below:

SAMPLE CODE:



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


HTTP Status Codes

Refer to the table below to view the IANA-registered status codes available in HTTPStatus class.






Also Read:



Comments