-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
When PyScript was announced at PyCon US 2022 I immediately tried to add support for synchronous HTTP requests w/ Pyodide/PyScript into urllib3 but was unfortunately unsuccessful at the time. I can see that support for this has grown since that time 🚀
There's a lot to look at and learn on this topic, this issue is currently a stub and needs more filling in.
General thoughts right now from me are having a new module urllib3.contrib.fetch
which exposes an HTTP[S]Connection
implementation that uses Pyodide's pyfetch (and the equivalent for emscripten) under the hood. Wouldn't need to support the full range of options available to urllib3 (things like custom certificates, etc) but I suspect we'd get a lot from just method, url, headers, body, and some other basic features.
The tougher parts of this would be testing and documentation, we can learn from the below projects potentially?
Requirements
- Figure out how we can test urllib3 consistently in a browser
- Add functionality which uses the JavaScript fetch API instead of httplib in a third-party module (ie
urllib3.contrib.fetch
) - Document the new feature and restrictions
- Verify that Requests works with urllib3 in the browser
Related projects / issues
- https://github.com/koenvo/pyodide-http
- https://github.com/emscripten-forge/requests-wasm-polyfill
- Integrate functionality into urllib3 koenvo/pyodide-http#28
- merge with https://github.com/emscripten-forge/requests-wasm-polyfill koenvo/pyodide-http#6
- Add Python
requests
API as a wrapper aroundpyfetch
to help Python native users. pyodide/pyodide#3160
cc @koenvo