Skip to content

Native support for Pyodide, PyScript (emscripten?) #2951

@sethmlarson

Description

@sethmlarson

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

cc @koenvo

Metadata

Metadata

Assignees

No one assigned

    Labels

    💰 Bounty $500If you complete this issue we'll pay you $500 on OpenCollective!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions