Live data from Hacker News

Python HTTP library 'urllib3' now works in the browser

github.com

1–10 of 35 posts

Re: Python HTTP library 'urllib3' now works in the browser

#4

Pyodide examples using urllib3 in browser still requires using fetch, so this still requires javascript. What does this practically mean? Does this ever point to a future where we can use urlib3 instead of fetch?

Lead maintainer of urllib3 here: We're tracking all the options for how we can make the experience better for folks looking to use Python in the browser. Today our biggest blocker is that there's no socket or TLS APIs for Emscripten/WASI. If those were to become available we'd jump on them right away :)

I think the biggest benefit of a foundational project like urllib3 getting browser support is that /many/ Python projects are built on top of urllib3 and many of them likely work in browsers now that urllib3 works in the browser.

For example, Requests is built on top of urllib3 and now gets browser support for free! And this is recursive, how many projects use Requests (spoiler: many). Pretty exciting IMO :)

Re: Python HTTP library 'urllib3' now works in the browser

#5

Pyodide examples using urllib3 in browser still requires using fetch, so this still requires javascript. What does this practically mean? Does this ever point to a future where we can use urlib3 instead of fetch?

Lead maintainer of urllib3 here: We're tracking all the options for how we can make the experience better for folks looking to use Python in the browser. Today our biggest blocker is that there's no socket or TLS APIs for Emscripten/WASI. If those were to become available we'd jump on them right away :) I think the biggest benefit of a foundational project like urllib3 getting browser support is that /many/ Python pr…

wow that's awesome. That we could even talk about potentially using just python to make requests in browser is pretty wild (of course, as you say still blocks in the way - lack of socket or TLS APIs for Emscripten/WASI). Really cool stuff tho. All the best eh and thank you VERY much for the incredible urllib3 library.

Re: Python HTTP library 'urllib3' now works in the browser

#6

Pyodide examples using urllib3 in browser still requires using fetch, so this still requires javascript. What does this practically mean? Does this ever point to a future where we can use urlib3 instead of fetch?

Lead maintainer of urllib3 here: We're tracking all the options for how we can make the experience better for folks looking to use Python in the browser. Today our biggest blocker is that there's no socket or TLS APIs for Emscripten/WASI. If those were to become available we'd jump on them right away :) I think the biggest benefit of a foundational project like urllib3 getting browser support is that /many/ Python pr…

Do you know if there are some plans for sockets or TLS APIs or are we far away from this?

Re: Python HTTP library 'urllib3' now works in the browser

#7

Earlier quoted context omitted.

Lead maintainer of urllib3 here: We're tracking all the options for how we can make the experience better for folks looking to use Python in the browser. Today our biggest blocker is that there's no socket or TLS APIs for Emscripten/WASI. If those were to become available we'd jump on them right away :) I think the biggest benefit of a foundational project like urllib3 getting browser support is that /many/ Python pr…

Do you know if there are some plans for sockets or TLS APIs or are we far away from this?

Browsers limit the ability for these platforms to use raw sockets, there simply is no API for it. The best that can be done /today/ is to use WebSockets, which are not the same thing and can't be used for HTTP requests without the server expecting a WebSocket connection:

https://github.com/emscripten-core/emscripten/issues/5196#is...

Re: Python HTTP library 'urllib3' now works in the browser

#8

Pyodide examples using urllib3 in browser still requires using fetch, so this still requires javascript. What does this practically mean? Does this ever point to a future where we can use urlib3 instead of fetch?

Am I misunderstanding this? You need JS to load the WASM module anyways, what does "requiring JS" means here?

Re: Python HTTP library 'urllib3' now works in the browser

#9
post #8

Pyodide examples using urllib3 in browser still requires using fetch, so this still requires javascript. What does this practically mean? Does this ever point to a future where we can use urlib3 instead of fetch?

Am I misunderstanding this? You need JS to load the WASM module anyways, what does "requiring JS" means here?

It means that urllib3 (python code) isn't actually making the http request (it's not making the tcp connection, tls auth, writing the request, or serializing the request headers ...)

It may be better to describe this as a "shim". Any python code that depended on urllib3 is now transparently shimmed in browser context to use the fetch-api instead. Which is useful.

Re: Python HTTP library 'urllib3' now works in the browser

#10
post #8

Pyodide examples using urllib3 in browser still requires using fetch, so this still requires javascript. What does this practically mean? Does this ever point to a future where we can use urlib3 instead of fetch?

Am I misunderstanding this? You need JS to load the WASM module anyways, what does "requiring JS" means here?

You’re right. It just reflected a momentary misunderstanding of mine. WASM still requires JS.
Post reply on HN