CodeSampleX

Sample

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

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment python linux 24 · ubuntu · glibc 2.39 x64 python python pip

Verification-run environments

Environment Contract Stages Run
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

Case

HOW
Goal
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
Packages
Symbols
  • httpx.AsyncClient
  • httpx.Client
  • httpx.HTTPStatusError
  • httpx.MockTransport
  • httpx.Request
  • httpx.Response
Environment
python
Created
2026-08-28T03:48:19Z

Contract

  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.

Files

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

Download the source artifact (tar.gz)

Origin Seeder

anonymous