Live data from Hacker News

Python HTTP library 'urllib3' now works in the browser

github.com

21–30 of 35 posts

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

#22

Earlier quoted context omitted.

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...

Sure, sorry if it wasn't clear from my question, it wasn't specifically about urllib3, but I meant if there are plans that browsers will make such an API available or if this is something that will never become real.

I doubt browsers would allow this, though gamedevs have wanted it for decades now. Particularly UDP.

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

#23

Earlier quoted context omitted.

Sure, sorry if it wasn't clear from my question, it wasn't specifically about urllib3, but I meant if there are plans that browsers will make such an API available or if this is something that will never become real.

I doubt browsers would allow this, though gamedevs have wanted it for decades now. Particularly UDP.

isn't the udp problem fixed with http3 unreliable webtransport?

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

#24
post #23

Earlier quoted context omitted.

I doubt browsers would allow this, though gamedevs have wanted it for decades now. Particularly UDP.

isn't the udp problem fixed with http3 unreliable webtransport?

Is it? That would be cool. Under the hood is it actual udp?

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

#25
Incredible! Two years ago I was experimenting in porting some code at the company I was at to python in the browser (instead of QT desktop apps) and this was the biggest thing I had to work around! I had to manually monkey patch or proxy a few libraries to make them work, but I'll have to test out this update and see if everything magically works

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

#26
post #11

why would you want to run python in the browser? Anyone can ELI5?

The film (especially vfx) industry runs on Python, and so much code is written for Python.

Same reason you'd want to run your server in node.js so it matches your front end code ( and you can reuse code on the front end and backend). Pyscript lets us have the same programming language in the front end and the backend, and access to all of our internal packages on the front end.

A lot of vfx software is written in QT, so at a previous company I actually made a wrapper around a subset of the QT interface and widgets, and replicated it in Pyscript, so we could write an app once and run it from inside vfx applications, or run it in the browser with no additional coding. It wasn't perfect, but it worked and made things simpler

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

#27

Incredible! Two years ago I was experimenting in porting some code at the company I was at to python in the browser (instead of QT desktop apps) and this was the biggest thing I had to work around! I had to manually monkey patch or proxy a few libraries to make them work, but I'll have to test out this update and see if everything magically works

Oh wow, thanks for this story! Would love to hear more if you have time :) Good luck with testing it out.

Note that we found an issue w/ emitting an InsecureRequestWarning by default. The request is perfectly secure, it's just we aren't telling the ConnectionPool that information (see: https://github.com/urllib3/urllib3/issues/3331)

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

#28
post #23

Earlier quoted context omitted.

isn't the udp problem fixed with http3 unreliable webtransport?

Is it? That would be cool. Under the hood is it actual udp?

HTTP3 uses QUIC, it's not "pure" UDP, but it's a protocol based on it

https://en.wikipedia.org/wiki/QUIC

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

#29
post #9
post #8

Earlier quoted context omitted.

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.

This is definitely out of scope for web browsers. The security implications of allowing arbitrary sockets are prohibitive.

To do something like that then you’re going to need a different environment with a different set of security guarantees and expectations, more like a shell where the user is responsible for vouching for the code’s trustworthiness.

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

#30
post #23

Earlier quoted context omitted.

isn't the udp problem fixed with http3 unreliable webtransport?

Is it? That would be cool. Under the hood is it actual udp?

its udp with encryption and congestion control, but the aspects that gamedevs like about udp, low latency and out of order delivery without head of line blocking are features

https://developer.chrome.com/docs/capabilities/web-apis/webt...

Post reply on HN