Repository navigation
feat(cpython): own requests and httpx modules over the HTTP bridge - #2572
Merged
Merged
Conversation
`import requests`, `import httpx` and `import httpx2` work in the CPython guest. Compact implementations of the common API call the host bridge directly and are preloaded in the snapshot, so importing them is free (vendored upstream requests cost ~3.1 s per call on Pulley). A differential test checks them against upstream requests and httpx. Claude-Session: https://claude.ai/code/session_01Ke1iW2hQi9VXioZi1avPaW
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 563a489 | Commit Preview URL Branch Preview URL |
Oct 07 2026, 03:55 PM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
import requests,import httpxandimport httpx2work in the CPython (cpythonfeature)python3. They are bashkit's own compact implementations of the common API, written on top of the HTTP bridge from #2568, so every request still goes through the network allowlist, SSRF checks, credential injection and the response cap. They are preloaded in the snapshot, so importing them costs nothing.Session, along with params, data, json, files, headers, cookies, basic auth, timeouts, redirects and hooks.Responsehelpers, and the upstream exception hierarchy.stream(), plusClientandAsyncClientwith base_url, follow_redirects, event hooks andMockTransport. AlsoURL,Headers,QueryParams,Cookies,Timeout,codes, and the upstream exceptions.Authorizationis dropped on a cross-host redirect. Each redirect hop is re-checked by the host.getresponse(), as in CPython.Why
Upstream
requests+ urllib3 + idna + charset_normalizer import 155 modules and cost ~3.1 s per call on Pulley (urllib3 alone 1.3 s). Every call starts from the snapshot, so that cost repeats on every call. Agents mostly use the common API surface.Before / After
Before:
python3 -c 'import requests'givesModuleNotFoundError. Bundling upstream made the same call take ~3.1 s.After (criterion, Pulley):
python_call/cpython/printpython_import/cpython/requests_httpx(import requests, httpx)Differential test vs upstream
requests2.34.2 /httpx0.28.1 (same 9 scenarios, shared fake server, output must match line for line):It caught two divergences, both fixed:
Truein requests params, and httpx'sHostheader.Risk
Checklist
import requeststo fail now checksnumpy.Generated by Claude Code