> **Источник:** https://python-all.ru/3.6/library/http.html
>
> «Документация Python на русском» – неофициальный перевод официальной документации Python: версии от 2.6 до 3.16, полнотекстовый поиск, английский оригинал рядом с переводом. Эта Markdown-версия страницы предназначена для работы с LLM: вставьте её в ChatGPT, Claude или Cursor.

---

# 21.11. [`http`](https://python-all.ru/3.6/library/http.html#module-http) – модули HTTP

**Исходный код:** [Lib/http/\_\_init\_\_.py](https://python-all.ru/src/3.6/Lib/http/__init__.py)

---

[`http`](https://python-all.ru/3.6/library/http.html#module-http) – пакет, объединяющий несколько модулей для работы с протоколом передачи гипертекста (HTTP):

- [`http.client`](https://python-all.ru/3.6/library/http.client.html#module-http.client) – низкоуровневый клиент протокола HTTP; для открытия URL на высоком уровне используйте [`urllib.request`](https://python-all.ru/3.6/library/urllib.request.html#module-urllib.request)
- [`http.server`](https://python-all.ru/3.6/library/http.server.html#module-http.server) содержит базовые классы HTTP-сервера на основе [`socketserver`](https://python-all.ru/3.6/library/socketserver.html#module-socketserver)
- [`http.cookies`](https://python-all.ru/3.6/library/http.cookies.html#module-http.cookies) содержит утилиты для реализации управления состоянием с помощью куки
- [`http.cookiejar`](https://python-all.ru/3.6/library/http.cookiejar.html#module-http.cookiejar) обеспечивает сохранение куки

[`http`](https://python-all.ru/3.6/library/http.html#module-http) также является модулем, который определяет ряд кодов состояния HTTP и связанные с ними сообщения через перечисление [`http.HTTPStatus`](https://python-all.ru/3.6/library/http.html#http.HTTPStatus):

#### `class http.HTTPStatus`

Новое в версии 3.5.

Подкласс [`enum.IntEnum`](https://python-all.ru/3.6/library/enum.html#enum.IntEnum), определяющий набор HTTP-статусов, поясняющих фраз и подробных описаний на английском языке.

Использование:

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

## 21.11.1. Коды состояния HTTP

Поддерживаемые, [зарегистрированные IANA](https://python-all.ru/3.6/library/http.html) коды состояния, доступные в [`http.HTTPStatus`](https://python-all.ru/3.6/library/http.html#http.HTTPStatus):

| Код | Имя перечисления | Подробности |
| --- | --- | --- |
| `100` | `CONTINUE` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.2.1 |
| `101` | `SWITCHING_PROTOCOLS` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.2.2 |
| `102` | `PROCESSING` | WebDAV [**RFC 2518**](https://python-all.ru/3.6/library/http.html), раздел 10.1 |
| `200` | `OK` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.3.1 |
| `201` | `CREATED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.3.2 |
| `202` | `ACCEPTED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.3.3 |
| `203` | `NON_AUTHORITATIVE_INFORMATION` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.3.4 |
| `204` | `NO_CONTENT` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.3.5 |
| `205` | `RESET_CONTENT` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.3.6 |
| `206` | `PARTIAL_CONTENT` | HTTP/1.1 [**RFC 7233**](https://python-all.ru/3.6/library/http.html), раздел 4.1 |
| `207` | `MULTI_STATUS` | WebDAV [**RFC 4918**](https://python-all.ru/3.6/library/http.html), раздел 11.1 |
| `208` | `ALREADY_REPORTED` | Расширения привязки WebDAV [**RFC 5842**](https://python-all.ru/3.6/library/http.html), раздел 7.1 (экспериментальный) |
| `226` | `IM_USED` | Дельта-кодирование в HTTP [**RFC 3229**](https://python-all.ru/3.6/library/http.html), раздел 10.4.1 |
| `300` | `MULTIPLE_CHOICES` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.4.1 |
| `301` | `MOVED_PERMANENTLY` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.4.2 |
| `302` | `FOUND` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.4.3 |
| `303` | `SEE_OTHER` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.4.4 |
| `304` | `NOT_MODIFIED` | HTTP/1.1 [**RFC 7232**](https://python-all.ru/3.6/library/http.html), раздел 4.1 |
| `305` | `USE_PROXY` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.4.5 |
| `307` | `TEMPORARY_REDIRECT` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.4.7 |
| `308` | `PERMANENT_REDIRECT` | Постоянное перенаправление [**RFC 7238**](https://python-all.ru/3.6/library/http.html), раздел 3 (экспериментальный) |
| `400` | `BAD_REQUEST` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.5.1 |
| `401` | `UNAUTHORIZED` | HTTP/1.1 аутентификация [**RFC 7235**](https://python-all.ru/3.6/library/http.html), раздел 3.1 |
| `402` | `PAYMENT_REQUIRED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.5.2 |
| `403` | `FORBIDDEN` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.5.3 |
| `404` | `NOT_FOUND` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.5.4 |
| `405` | `METHOD_NOT_ALLOWED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.5.5 |
| `406` | `NOT_ACCEPTABLE` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.5.6 |
| `407` | `PROXY_AUTHENTICATION_REQUIRED` | HTTP/1.1 аутентификация [**RFC 7235**](https://python-all.ru/3.6/library/http.html), раздел 3.2 |
| `408` | `REQUEST_TIMEOUT` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.5.7 |
| `409` | `CONFLICT` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.5.8 |
| `410` | `GONE` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.5.9 |
| `411` | `LENGTH_REQUIRED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.5.10 |
| `412` | `PRECONDITION_FAILED` | HTTP/1.1 [**RFC 7232**](https://python-all.ru/3.6/library/http.html), раздел 4.2 |
| `413` | `REQUEST_ENTITY_TOO_LARGE` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.5.11 |
| `414` | `REQUEST_URI_TOO_LONG` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.5.12 |
| `415` | `UNSUPPORTED_MEDIA_TYPE` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.5.13 |
| `416` | `REQUEST_RANGE_NOT_SATISFIABLE` | HTTP/1.1 запросы диапазона [**RFC 7233**](https://python-all.ru/3.6/library/http.html), раздел 4.4 |
| `417` | `EXPECTATION_FAILED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.5.14 |
| `422` | `UNPROCESSABLE_ENTITY` | WebDAV [**RFC 4918**](https://python-all.ru/3.6/library/http.html), раздел 11.2 |
| `423` | `LOCKED` | WebDAV [**RFC 4918**](https://python-all.ru/3.6/library/http.html), Раздел 11.3 |
| `424` | `FAILED_DEPENDENCY` | WebDAV [**RFC 4918**](https://python-all.ru/3.6/library/http.html), Раздел 11.4 |
| `426` | `UPGRADE_REQUIRED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.5.15 |
| `428` | `PRECONDITION_REQUIRED` | Дополнительные коды состояния HTTP [**RFC 6585**](https://python-all.ru/3.6/library/http.html) |
| `429` | `TOO_MANY_REQUESTS` | Дополнительные коды состояния HTTP [**RFC 6585**](https://python-all.ru/3.6/library/http.html) |
| `431` | `REQUEST_HEADER_FIELDS_TOO_LARGE` | Дополнительные коды состояния HTTP [**RFC 6585**](https://python-all.ru/3.6/library/http.html) |
| `500` | `INTERNAL_SERVER_ERROR` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.6.1 |
| `501` | `NOT_IMPLEMENTED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.6.2 |
| `502` | `BAD_GATEWAY` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.6.3 |
| `503` | `SERVICE_UNAVAILABLE` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.6.4 |
| `504` | `GATEWAY_TIMEOUT` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.6.5 |
| `505` | `HTTP_VERSION_NOT_SUPPORTED` | HTTP/1.1 [**RFC 7231**](https://python-all.ru/3.6/library/http.html), раздел 6.6.6 |
| `506` | `VARIANT_ALSO_NEGOTIATES` | Прозрачное согласование содержимого в HTTP [**RFC 2295**](https://python-all.ru/3.6/library/http.html), раздел 8.1 (экспериментальный) |
| `507` | `INSUFFICIENT_STORAGE` | WebDAV [**RFC 4918**](https://python-all.ru/3.6/library/http.html), раздел 11.5 |
| `508` | `LOOP_DETECTED` | Расширения привязки WebDAV [**RFC 5842**](https://python-all.ru/3.6/library/http.html), раздел 7.2 (экспериментальный) |
| `510` | `NOT_EXTENDED` | Расширяемая структура HTTP [**RFC 2774**](https://python-all.ru/3.6/library/http.html), раздел 7 (экспериментальный) |
| `511` | `NETWORK_AUTHENTICATION_REQUIRED` | Дополнительные коды состояния HTTP [**RFC 6585**](https://python-all.ru/3.6/library/http.html), раздел 6 |

Для сохранения обратной совместимости значения перечисления также присутствуют в модуле [`http.client`](https://python-all.ru/3.6/library/http.client.html#module-http.client) в виде констант. Имя перечисления совпадает с именем константы (т.е. `http.HTTPStatus.OK` также доступно как `http.client.OK`).
