http.md
1> **Источник:** https://python-all.ru/3.7/library/http.html2>3> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.45---67# [`http`](https://python-all.ru/3.7/library/http.html#module-http) – модули HTTP89**Исходный код:** [Lib/http/\_\_init\_\_.py](https://python-all.ru/src/3.7/Lib/http/__init__.py)1011---1213[`http`](https://python-all.ru/3.7/library/http.html#module-http) – пакет, объединяющий несколько модулей для работы с протоколом передачи гипертекста (HTTP):1415- [`http.client`](https://python-all.ru/3.7/library/http.client.html#module-http.client) – низкоуровневый клиент протокола HTTP; для открытия URL на высоком уровне используйте [`urllib.request`](https://python-all.ru/3.7/library/urllib.request.html#module-urllib.request)16- [`http.server`](https://python-all.ru/3.7/library/http.server.html#module-http.server) содержит базовые классы HTTP-сервера на основе [`socketserver`](https://python-all.ru/3.7/library/socketserver.html#module-socketserver)17- [`http.cookies`](https://python-all.ru/3.7/library/http.cookies.html#module-http.cookies) содержит утилиты для реализации управления состоянием с помощью куки18- [`http.cookiejar`](https://python-all.ru/3.7/library/http.cookiejar.html#module-http.cookiejar) обеспечивает сохранение куки1920[`http`](https://python-all.ru/3.7/library/http.html#module-http) также является модулем, который определяет ряд кодов состояния HTTP и связанные с ними сообщения через перечисление [`http.HTTPStatus`](https://python-all.ru/3.7/library/http.html#http.HTTPStatus):2122#### `class http.HTTPStatus`2324Новое в версии 3.5.2526Подкласс [`enum.IntEnum`](https://python-all.ru/3.7/library/enum.html#enum.IntEnum), определяющий набор HTTP-статусов, поясняющих фраз и подробных описаний на английском языке.2728Использование:2930```python31>>> from http import HTTPStatus32>>> HTTPStatus.OK33<HTTPStatus.OK: 200>34>>> HTTPStatus.OK == 20035True36>>> HTTPStatus.OK.value3720038>>> HTTPStatus.OK.phrase39'OK'40>>> HTTPStatus.OK.description41'Request fulfilled, document follows'42>>> list(HTTPStatus)43[<HTTPStatus.CONTINUE: 100>, <HTTPStatus.SWITCHING_PROTOCOLS: 101>, ...]44```4546## Коды состояния HTTP4748Поддерживаемые, [зарегистрированные IANA](https://python-all.ru/3.7/library/http.html) коды состояния, доступные в [`http.HTTPStatus`](https://python-all.ru/3.7/library/http.html#http.HTTPStatus):4950| Код | Имя перечисления | Подробности |51| --- | --- | --- |52| `100` | `CONTINUE` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.2.1 |53| `101` | `SWITCHING_PROTOCOLS` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.2.2 |54| `102` | `PROCESSING` | WebDAV [**RFC 2518**](https://python-all.ru/3.7/library/http.html), раздел 10.1 |55| `200` | `OK` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.3.1 |56| `201` | `CREATED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.3.2 |57| `202` | `ACCEPTED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.3.3 |58| `203` | `NON_AUTHORITATIVE_INFORMATION` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.3.4 |59| `204` | `NO_CONTENT` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.3.5 |60| `205` | `RESET_CONTENT` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.3.6 |61| `206` | `PARTIAL_CONTENT` | HTTP/1.1 [**RFC 7233**](https://python-all.ru/3.7/library/http.html), раздел 4.1 |62| `207` | `MULTI_STATUS` | WebDAV [**RFC 4918**](https://python-all.ru/3.7/library/http.html), раздел 11.1 |63| `208` | `ALREADY_REPORTED` | Расширения привязки WebDAV [**RFC 5842**](https://python-all.ru/3.7/library/http.html), раздел 7.1 (экспериментальный) |64| `226` | `IM_USED` | Дельта-кодирование в HTTP [**RFC 3229**](https://python-all.ru/3.7/library/http.html), раздел 10.4.1 |65| `300` | `MULTIPLE_CHOICES` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.4.1 |66| `301` | `MOVED_PERMANENTLY` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.4.2 |67| `302` | `FOUND` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.4.3 |68| `303` | `SEE_OTHER` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.4.4 |69| `304` | `NOT_MODIFIED` | HTTP/1.1 [**RFC 7232**](https://python-all.ru/3.7/library/http.html), раздел 4.1 |70| `305` | `USE_PROXY` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.4.5 |71| `307` | `TEMPORARY_REDIRECT` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.4.7 |72| `308` | `PERMANENT_REDIRECT` | Постоянное перенаправление [**RFC 7238**](https://python-all.ru/3.7/library/http.html), раздел 3 (экспериментальный) |73| `400` | `BAD_REQUEST` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.5.1 |74| `401` | `UNAUTHORIZED` | HTTP/1.1 аутентификация [**RFC 7235**](https://python-all.ru/3.7/library/http.html), раздел 3.1 |75| `402` | `PAYMENT_REQUIRED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.5.2 |76| `403` | `FORBIDDEN` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.5.3 |77| `404` | `NOT_FOUND` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.5.4 |78| `405` | `METHOD_NOT_ALLOWED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.5.5 |79| `406` | `NOT_ACCEPTABLE` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.5.6 |80| `407` | `PROXY_AUTHENTICATION_REQUIRED` | HTTP/1.1 аутентификация [**RFC 7235**](https://python-all.ru/3.7/library/http.html), раздел 3.2 |81| `408` | `REQUEST_TIMEOUT` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.5.7 |82| `409` | `CONFLICT` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.5.8 |83| `410` | `GONE` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.5.9 |84| `411` | `LENGTH_REQUIRED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.5.10 |85| `412` | `PRECONDITION_FAILED` | HTTP/1.1 [**RFC 7232**](https://python-all.ru/3.7/library/http.html), раздел 4.2 |86| `413` | `REQUEST_ENTITY_TOO_LARGE` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.5.11 |87| `414` | `REQUEST_URI_TOO_LONG` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.5.12 |88| `415` | `UNSUPPORTED_MEDIA_TYPE` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.5.13 |89| `416` | `REQUESTED_RANGE_NOT_SATISFIABLE` | HTTP/1.1 запросы диапазона [**RFC 7233**](https://python-all.ru/3.7/library/http.html), раздел 4.4 |90| `417` | `EXPECTATION_FAILED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.5.14 |91| `421` | `MISDIRECTED_REQUEST` | HTTP/2 [**RFC 7540**](https://python-all.ru/3.7/library/http.html), раздел 9.1.2 |92| `422` | `UNPROCESSABLE_ENTITY` | WebDAV [**RFC 4918**](https://python-all.ru/3.7/library/http.html), раздел 11.2 |93| `423` | `LOCKED` | WebDAV [**RFC 4918**](https://python-all.ru/3.7/library/http.html), Раздел 11.3 |94| `424` | `FAILED_DEPENDENCY` | WebDAV [**RFC 4918**](https://python-all.ru/3.7/library/http.html), Раздел 11.4 |95| `426` | `UPGRADE_REQUIRED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.5.15 |96| `428` | `PRECONDITION_REQUIRED` | Дополнительные коды состояния HTTP [**RFC 6585**](https://python-all.ru/3.7/library/http.html) |97| `429` | `TOO_MANY_REQUESTS` | Дополнительные коды состояния HTTP [**RFC 6585**](https://python-all.ru/3.7/library/http.html) |98| `431` | `REQUEST_HEADER_FIELDS_TOO_LARGE` | Дополнительные коды состояния HTTP [**RFC 6585**](https://python-all.ru/3.7/library/http.html) |99| `500` | `INTERNAL_SERVER_ERROR` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.6.1 |100| `501` | `NOT_IMPLEMENTED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.6.2 |101| `502` | `BAD_GATEWAY` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.6.3 |102| `503` | `SERVICE_UNAVAILABLE` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.6.4 |103| `504` | `GATEWAY_TIMEOUT` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.6.5 |104| `505` | `HTTP_VERSION_NOT_SUPPORTED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.7/library/http.html), раздел 6.6.6 |105| `506` | `VARIANT_ALSO_NEGOTIATES` | Прозрачное согласование содержимого в HTTP [**RFC 2295**](https://python-all.ru/3.7/library/http.html), раздел 8.1 (экспериментальный) |106| `507` | `INSUFFICIENT_STORAGE` | WebDAV [**RFC 4918**](https://python-all.ru/3.7/library/http.html), раздел 11.5 |107| `508` | `LOOP_DETECTED` | Расширения привязки WebDAV [**RFC 5842**](https://python-all.ru/3.7/library/http.html), раздел 7.2 (экспериментальный) |108| `510` | `NOT_EXTENDED` | Расширяемая структура HTTP [**RFC 2774**](https://python-all.ru/3.7/library/http.html), раздел 7 (экспериментальный) |109| `511` | `NETWORK_AUTHENTICATION_REQUIRED` | Дополнительные коды состояния HTTP [**RFC 6585**](https://python-all.ru/3.7/library/http.html), раздел 6 |110111Для сохранения обратной совместимости значения перечисления также присутствуют в модуле [`http.client`](https://python-all.ru/3.7/library/http.client.html#module-http.client) в виде констант. Имя перечисления совпадает с именем константы (т.е. `http.HTTPStatus.OK` также доступно как `http.client.OK`).112113Изменено в версии 3.7: Добавлен код состояния `421 MISDIRECTED_REQUEST`.114