> For the complete documentation index, see [llms.txt](https://docs.tumbler.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tumbler.app/ru/kontrakt-podpiski/fetcher-http-contract.md).

# HTTP контракт fetch URL

## Для кого

Команды провайдера, которые обслуживают `subscription` URL и хотят заранее учесть ограничения fetcher‑агента.

## Что можно сделать

* Проверить, что origin отвечает в строгом соответствии с правилами HTTP/HTTPS.
* Настроить редиректы и ограничения размера так, чтобы fetcher не возвращал ошибки.
* Убедиться, что кодировки и типы контента совместимы.

## Примеры

* Запрос: `GET https://provider.example.com/public/subscription` с `User-Agent: tumbler-backend-fetcher/1.0` и `Accept-Encoding: identity`.
* Редирект 302 на финальный `https://cdn.provider.example.com/subscription` (scheme/host/port разрешены).
* Ответ `304 Not Modified` при совпадении `If-None-Match` или `If-Modified-Since`.

## См. также

* [subscription/fetch-url.md](/ru/nachat/fetch-url.md)
* [operations/caching-and-304.md](/ru/uluchsheniya-posle-pervogo-zapuska/caching-and-304.md)
* [security/fetcher-restrictions.md](/ru/uluchsheniya-posle-pervogo-zapuska/fetcher-restrictions.md)

## Метод и заголовки

* Метод: только `GET`.
* `User-Agent`: `tumbler-backend-fetcher/1.0` (может быть `1.x` в будущих релизах, но префикс сохраняется).
* `Accept-Encoding: identity` — провайдер **не должен требовать** gzip/br/deflate; отдавайте несжатый ответ.
* Дополнительные заголовки от провайдера допускаются, но fetcher принудительно выставляет `User-Agent` и `Accept-Encoding` при каждом переходе.

## Политика редиректов

* Поддерживаются 301, 302, 307, 308.
* Лимит цепочки редиректов: до 10 переходов на один запрос; превышение даёт ошибку `REDIRECT_LIMIT`.
* Каждый hop проходит SSRF‑валидацию: разрешены только `http`/`https`, порты из allow‑list (по умолчанию 80/443), запрет localhost/внутренних адресов и userinfo. Детали — в [fetcher-restrictions.md](/ru/uluchsheniya-posle-pervogo-zapuska/fetcher-restrictions.md).
* Рекомендуется сразу перенаправлять на конечный HTTPS endpoint без «ступенчатых» цепочек.

## Размер ответа

* Жёсткий лимит тела: **до 2 MB**. Большее тело приводит к ошибке `BODY_TOO_LARGE` и ответ не используется.
* Рекомендуемый размер: **< 200 KB**, чтобы ускорить доставку и кэширование.
* Если CDN добавляет padding, убедитесь, что итоговый размер не превышает лимит.

## Кодировка и строки

* Тело должно быть в UTF‑8 без BOM.
* Рекомендуемые окончания строк — `\n` (LF); `\r\n` допустимо, но не добавляйте смешанные окончания.
* Пустые строки и завершающий перевод строки сохраняются как есть; избегайте случайных пробелов и табов в конце файла.

## Коды статуса

* `200 OK` — успешный ответ с телом.
* `304 Not Modified` — рекомендуется поддерживать через `If-None-Match`/`If-Modified-Since`; тело отсутствует.
* Любые `4xx`/`5xx` трактуются как ошибка fetch и приводят к ретраям/фолбэку; используйте точные коды (например, `429` с `Retry-After`).

## Content-Type

* Допустимые типы: `text/plain` или `application/json`.
* Указывайте `charset=utf-8`, чтобы избежать двусмысленной интерпретации.
* Другие типы могут игнорироваться или обрабатываться как ошибка совместимости.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.tumbler.app/ru/kontrakt-podpiski/fetcher-http-contract.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
