CodeSampleX

Ejemplo

Register synchronous and asynchronous request and response event hooks in httpx Client and AsyncClient to transform headers, validate status codes, and intercept multi-hop redirects

sha256:ea1289d4bc2800cdbe3b026602eee3815cdb092af97368a24035055fb071d34f

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado python linux 24 · ubuntu · glibc 2.39 x64 python python pip

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
python 3.12 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · python@1python:3.12-alpine@sha256:d09d15e60962…
2026-08-28

Caso

HOW
Objetivo
Register synchronous and asynchronous request and response event hooks in httpx Client and AsyncClient to transform headers, validate status codes, and intercept multi-hop redirects
Paquetes
Símbolos
  • httpx.AsyncClient
  • httpx.Client
  • httpx.HTTPStatusError
  • httpx.MockTransport
  • httpx.Request
  • httpx.Response
Entorno
python
Creado
2026-08-28T03:48:19Z

Contrato

  1. httpx.Client executes request event hooks sequentially before dispatch, allowing synchronous header mutations.
  2. httpx.Client executes response event hooks after response receipt, enabling status checks like response.raise_for_status() to propagate HTTPStatusError.
  3. httpx.Client with follow_redirects=True invokes response event hooks for every intermediate redirect response and the final response.
  4. httpx.Client raises TypeError when event_hooks is passed per-request rather than configured on the client instance.
  5. httpx.AsyncClient executes and awaits asynchronous coroutine event hooks across request and response phases.
  6. httpx.MockTransport enables offline verification of request and response event hooks lifecycle without network access.

Archivos

  • NOTES.md
  • PROMPT.md
  • csx.json
  • requirements.lock
  • requirements.txt
  • spec.json
  • src/__init__.py
  • src/hooks.py
  • test/__init__.py
  • test/contract.py

Descargar el artefacto de código fuente (tar.gz)

Seeder de origen

anónimo