Repository navigation
Commit 3932982
fix(client): handle case-insensitive SSE media types (#1464)
# Description
Streaming clients fail to parse a valid SSE response when the server
sends `Content-Type: Text/Event-Stream` (or another capitalization). The
shared helper treats it as a non-stream response and attempts to decode
the SSE envelope as JSON. HTTP media types and subtypes are
case-insensitive ([RFC 9110
§8.3.1](https://www.rfc-editor.org/rfc/rfc9110.html#section-8.3.1)).
Normalize the header before the existing SSE check. Both REST and
JSON-RPC transports share this helper. Add ten public-transport
regression/control cases covering lowercase, title case, uppercase,
mixed case with a charset parameter, and ordinary JSON responses.
Validation on upstream `14e799cb245c79e9f46bfb07763d7840b43e4cff`:
- Original implementation: six regression failures; four controls pass.
A local HTTP server also reproduces the parsing failure through the real
REST transport; both capitalization variants return the expected message
after the fix.
- `./scripts/lint.sh`: passes (three existing unused-suppression
warnings in untouched files).
- `uv run pytest`: 2596 passed, 207 skipped, 4 xfailed, 1 xpassed.
- `uv run pytest --cov=src --cov-report=term-missing
--cov-fail-under=88`: same test results, 94% total coverage.
The transport tests supply deterministic responses with
`httpx.MockTransport`; the separate HTTP reproduction uses a real
loopback server. These replace the external Agent endpoint only. No real
model/provider call was tested. Existing optional/database skips and
expected-failure markers remain unchanged.
- [x] Follow the CONTRIBUTING guide.
- [x] Use a conventional commit title.
- [x] Run tests and linters.
- [x] Documentation considered: no public API or configuration change.
AI assistance: OpenAI Codex helped investigate, implement, and validate
this change.
Co-authored-by: Elon-Jiang <191222665+Elon-Jiang@users.noreply.github.com>
Co-authored-by: OpenAI Codex <noreply@openai.com>
Co-authored-by: mykytanetipa <mykytanetipa@google.com>1 parent 569b94f commit 3932982
2 files changed
Lines changed: 85 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
177 | | - | |
178 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
0 commit comments