Document per-request HTTP headers for Streamable HTTP clients - #3288
Document per-request HTTP headers for Streamable HTTP clients#3288HaoChiBao wants to merge 2 commits into
Conversation
Show how contextvars plus an httpx2 request event hook on a shared AsyncClient cover per-call Authorization and trace headers without new Client API, addressing modelcontextprotocol#1966.
Avoid a partial-covered POST-only branch and match the usual session_manager pragma so fail_under=100 passes.
|
Thanks for the contribution. This repository only keeps pull requests open when they're linked to an issue that a maintainer has assigned to the author — CONTRIBUTING.md explains why and how we work. This PR has been closed for now because you aren't currently assigned to #1966. If a maintainer would like this change as a PR from you, they'll assign you to #1966 and this PR will reopen automatically — there's nothing more you need to do. (If you opened the issue, this PR already shows up on its timeline.) There's no need to open a new PR — this one will be reopened. While it's closed, please push any updates as new commits rather than force-pushing, since GitHub can't reopen a PR whose branch has been rewritten. Maintainers: reopening this PR, removing the |
Summary
contextvarsand anhttpx2event_hooks["request"]hook on a sharedAsyncClient(docs_src/client_transports/tutorial005.py+ section indocs/client/transports.md).Clientcall reach the request hook as headers over in-process Streamable HTTP.Fixes #1966
AI disclosure
AI-assisted drafting (Cursor). I reviewed the resulting docs/example/tests and verified them locally.
Test plan
uv run --frozen ruff format/ruff check --fixon touched filesuv run --frozen pyrighton touched filesuv run --frozen pytest tests/docs_src/test_client_transports.py -v(7 passed)--8<--snippet under Client transports → Per-request headers