Python Glossary Русский

Python 3.0+http.clientterm

http

module

A package for the HTTP protocol: a client, a simple server, cookies, and enums of status codes and request methods.

Syntax

from http import HTTPStatus

The package has four submodules: http.client is a low-level client, http.server is a simple development server, not for production, and http.cookies and http.cookiejar handle cookies on the server and client side. An ordinary request to a site is easier with urllib.request, while the http package itself provides HTTPStatus and HTTPMethod. In Python 2 these modules were called httplib, BaseHTTPServer, Cookie and cookielib.

Examples

from http import HTTPStatus
print(HTTPStatus.NOT_FOUND.value, HTTPStatus.NOT_FOUND.phrase)  # → 404 Not Found
print(HTTPStatus(200).name)  # → OK

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy