On this page
http.HTTPStatus
Prev: http.HTTPMethod | Up: http
Rel: http.HTTPMethod
Ref: docs.python.org — http.HTTPStatus
Tags: #public #python3 #stdlib #http
Import
import http
from http import HTTPStatus
Signature & Overview
http.HTTPStatus(*values)
HTTP status codes and reason phrases Status codes from the following RFCs are all observed: * RFC 9110: HTTP Semantics, obsoletes 7231, which obsoleted 2616
Methods & Attributes
HTTPStatus.as_integer_ratio(self, /)— Return a pair of integers, whose ratio is equal to the original int.HTTPStatus.bit_count(self, /)— Number of ones in the binary representation of the absolute value of self.HTTPStatus.bit_length(self, /)— Number of bits necessary to represent self in binary.HTTPStatus.conjugate(self, /)— Returns self, the complex conjugate of any int.HTTPStatus.from_bytes(bytes, byteorder='big', *, signed=False)— Return the integer represented by the given array of bytes.HTTPStatus.is_integer(self, /)— Returns True. Exists for duck type compatibility with float.is_integer.HTTPStatus.to_bytes(self, /, length=1, byteorder='big', *, signed=False)— Return an array of bytes representing an integer.
Usage
from http import HTTPStatus
status = HTTPStatus.NOT_FOUND
assert status == 404 and status.phrase == "Not Found"
assert HTTPStatus(200) is HTTPStatus.OK
Gotchas
IntEnumof standard HTTP status codes: Compares directly to integers (resp.status == HTTPStatus.OK) and exposes.phrase,.description, and.is_success(Python 3.12+).
REPL Inspect
from http import HTTPStatus
help(HTTPStatus)
Linked from
Related notes
- tuts/python3/stdlib_module/http/HTTPMethod Linked here; links to this page; shared tags: #http, #stdlib
- tuts/python3/stdlib_module/http Linked here; links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib
- tuts/c/stdlib/ctype/isdigit shared tags: #stdlib
- tuts/c/stdlib/ctype/isspace shared tags: #stdlib