Пример
Implement custom authentication in httpx via generator-based auth_flow, handling 401 challenge retries, payload buffering flags, and cross-origin redirect header stripping
sha256:8beca7b4089b38cfdeb21bb5dca8de9f6632eb54e66b117132c9e44357d26315
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Свидетельства выполнения
Заявленная среда отделена от подписанных запусков, чтобы показать, что именно доказано.
Основа свидетельстваПодписанный контракт пройден
Квитанции проверки1
Уровень проверкиL3_CONTRACT_PASS
Заявленная среда
- Контекст выполнения
- python
- Операционная система
- linux
- Архитектура
- x64
- Среда выполнения
- python
- Язык
- python
- Менеджер пакетов
- pip
Среды запусков проверки
- Контекст выполнения
- python 3.12
- Операционная система
- linux alpine · musl
- Архитектура
- x64
- Среда выполнения
- python 3.12
- Язык
- python
- Менеджер пакетов
- pip
- Выполнение
- container · docker
CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · python@1 · 2026-08-17
Кейс
- Цель
- Implement custom authentication in httpx via generator-based auth_flow, handling 401 challenge retries, payload buffering flags, and cross-origin redirect header stripping HOW
- Пакеты
-
httpx 0.28.1
- Окружение
- python
- Создан
- 2026-08-17T06:39:48Z
Что обычно предполагают
Subclassing Auth to inspect streaming request bodies or handle 401 challenge retries can be done by accessing request.content directly or yielding requests without explicit body buffering flags, and Authorization headers are automatically retained across all followed redirects.
Автор образца записал здесь то, чего ожидал бы разработчик или модель. Контракт ниже — это то, что действительно выполнялось.
Контракт
- Subclassing httpx.Auth requires a generator auth_flow yielding requests and receiving responses, preserving 401 challenge responses in history upon retry
- Accessing request.content on streaming requests inside auth_flow raises RequestNotRead unless requires_request_body is set to True
- Accessing response.content on streaming responses inside auth_flow raises ResponseNotRead unless requires_response_body is set to True
- Following redirects strips Authorization headers on cross-origin redirects while preserving them for same-origin destinations
- Client accepts (username, password) tuples as BasicAuth and callable functions as FunctionAuth, while rejecting non-callable types with TypeError
Файлы
- NOTES.md
- csx.json
- requirements.lock
- requirements.txt
- src/__init__.py
- src/auth_schemes.py
- test/__init__.py
- test/contract.py
Скачать артефакт с исходным кодом (tar.gz)
Исходный сидер
csx-seed
Квитанции проверки
- python 3.12 · linux alpine/x64 · docker · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · python@1 · 2026-08-17 · ed25519:d91480838ac982c9