On this page
http.HTTPMethod
Up: http | Next: http.HTTPStatus
Rel: http.HTTPStatus
Ref: docs.python.org — http.HTTPMethod
Tags: #public #python3 #stdlib #http
Import
import http
from http import HTTPMethod
Signature & Overview
http.HTTPMethod(*values)
HTTP methods and descriptions Methods from the following RFCs are all observed: * RFC 9110: HTTP Semantics, obsoletes 7231, which obsoleted 2616
Methods & Attributes
HTTPMethod.capitalize(self, /)— Return a capitalized version of the string.HTTPMethod.casefold(self, /)— Return a version of the string suitable for caseless comparisons.HTTPMethod.center(self, width, fillchar=' ', /)— Return a centered string of length width.HTTPMethod.count(...)— Return the number of non-overlapping occurrences of substring sub in string S[start:end].HTTPMethod.encode(self, /, encoding='utf-8', errors='strict')— Encode the string using the codec registered for encoding.HTTPMethod.endswith(...)— Return True if the string ends with the specified suffix, False otherwise.HTTPMethod.expandtabs(self, /, tabsize=8)— Return a copy where all tab characters are expanded using spaces.HTTPMethod.find(...)— Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].HTTPMethod.format(self, /, *args, **kwargs)— Return a formatted version of the string, using substitutions from args and kwargs.HTTPMethod.format_map(self, mapping, /)— Return a formatted version of the string, using substitutions from mapping.HTTPMethod.index(...)— Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].HTTPMethod.isalnum(self, /)— Return True if the string is an alpha-numeric string, False otherwise.HTTPMethod.isalpha(self, /)— Return True if the string is an alphabetic string, False otherwise.HTTPMethod.isascii(self, /)— Return True if all characters in the string are ASCII, False otherwise.HTTPMethod.isdecimal(self, /)— Return True if the string is a decimal string, False otherwise.HTTPMethod.isdigit(self, /)— Return True if the string is a digit string, False otherwise.HTTPMethod.isidentifier(self, /)— Return True if the string is a valid Python identifier, False otherwise.HTTPMethod.islower(self, /)— Return True if the string is a lowercase string, False otherwise.HTTPMethod.isnumeric(self, /)— Return True if the string is a numeric string, False otherwise.HTTPMethod.isprintable(self, /)— Return True if all characters in the string are printable, False otherwise.HTTPMethod.isspace(self, /)— Return True if the string is a whitespace string, False otherwise.HTTPMethod.istitle(self, /)— Return True if the string is a title-cased string, False otherwise.HTTPMethod.isupper(self, /)— Return True if the string is an uppercase string, False otherwise.HTTPMethod.join(self, iterable, /)— Concatenate any number of strings.HTTPMethod.ljust(self, width, fillchar=' ', /)— Return a left-justified string of length width.HTTPMethod.lower(self, /)— Return a copy of the string converted to lowercase.HTTPMethod.lstrip(self, chars=None, /)— Return a copy of the string with leading whitespace removed.HTTPMethod.maketrans(...)— Return a translation table usable for str.translate().HTTPMethod.partition(self, sep, /)— Partition the string into three parts using the given separator.HTTPMethod.removeprefix(self, prefix, /)— Return a str with the given prefix string removed if present.HTTPMethod.removesuffix(self, suffix, /)— Return a str with the given suffix string removed if present.HTTPMethod.replace(self, old, new, /, count=-1)— Return a copy with all occurrences of substring old replaced by new.HTTPMethod.rfind(...)— Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].HTTPMethod.rindex(...)— Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].HTTPMethod.rjust(self, width, fillchar=' ', /)— Return a right-justified string of length width.HTTPMethod.rpartition(self, sep, /)— Partition the string into three parts using the given separator.HTTPMethod.rsplit(self, /, sep=None, maxsplit=-1)— Return a list of the substrings in the string, using sep as the separator string.HTTPMethod.rstrip(self, chars=None, /)— Return a copy of the string with trailing whitespace removed.HTTPMethod.split(self, /, sep=None, maxsplit=-1)— Return a list of the substrings in the string, using sep as the separator string.HTTPMethod.splitlines(self, /, keepends=False)— Return a list of the lines in the string, breaking at line boundaries.
Usage
from http import HTTPMethod
assert HTTPMethod.GET == "GET"
assert HTTPMethod.POST.description.startswith("Perform")
Gotchas
- Requires Python 3.11+ (
StrEnum): Compares directly to uppercase method strings ("GET","POST","DELETE") and avoids typos.
REPL Inspect
from http import HTTPMethod
help(HTTPMethod)
Linked from
Related notes
- tuts/python3/stdlib_module/http/HTTPStatus 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