CodeSampleX

Sample

Consume Server-Sent Events streams and decode structured event data with EventSource in httpx2

sha256:92a6d836b66a59ab8ea1e28fea8f909642fe573509ea5257a28ba3ed0053a446

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 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
Consume Server-Sent Events streams and decode structured event data with EventSource in httpx2
Packages
Symbols
  • httpx2.EventSource
  • httpx2.SSEError
  • httpx2.ServerSentEvent
Environment
python
Created
2026-08-28T06:33:51Z

Contract

  1. assert iterating over EventSource(response) yields ServerSentEvent instances from a text/event-stream response
  2. assert ServerSentEvent parses custom event types, last event ID, retry interval, and multiline data payloads
  3. assert ServerSentEvent.json() deserializes JSON payloads from the event data field
  4. assert EventSource raises SSEError when response Content-Type is not text/event-stream
  5. assert EventSource raises SSEError when a single event exceeds max_event_size

Files

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

Download the source artifact (tar.gz)

Origin Seeder

anonymous