TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Python HTTP library 'urllib3' now works in the browser

108 pointsby SethMLarsonover 1 year ago

6 comments

codingglassover 1 year ago
This a a great example of good work getting &#x27;upstreamed.&#x27; The go-to solution for using requests and urllib3 in the browser had been Koen Vossen&#x27;s &#x27;pyodide-http&#x27; package, which you&#x27;d install in PyScript&#x2F;Pyodide and then call &#x27;pyodide_http.patch_all()`. It monkey-patched requests and urllib3 to use the browser API&#x27;s. [1]<p>Then &#x27;pyodide-http&#x27; got adopted into the Pyodide-included packages[2], so you didn&#x27;t have to specify it for install, just import it and run patch_all().<p>And now a similar technique has been incorporated directly into urllib3. (Not a direct port - as far as I know Joe Marshall and others did a full reimplementation so that urllib3&#x27;s API&#x27;s would be maintained as much as possible). [2]<p>Very cool.<p>Edit: Looks like there&#x27;s a note to this same effect on Seth Larson&#x27;s post about urllib3&#x27;s future. [3]<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;koenvo&#x2F;pyodide-http">https:&#x2F;&#x2F;github.com&#x2F;koenvo&#x2F;pyodide-http</a><p>[2] <a href="https:&#x2F;&#x2F;pyodide.org&#x2F;en&#x2F;stable&#x2F;usage&#x2F;packages-in-pyodide.html" rel="nofollow">https:&#x2F;&#x2F;pyodide.org&#x2F;en&#x2F;stable&#x2F;usage&#x2F;packages-in-pyodide.html</a><p>[3] <a href="https:&#x2F;&#x2F;sethmlarson.dev&#x2F;urllib3-is-fundraising-for-http2-support#support-for-webassembly-and-emscripten" rel="nofollow">https:&#x2F;&#x2F;sethmlarson.dev&#x2F;urllib3-is-fundraising-for-http2-sup...</a>
Austizzleover 1 year ago
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&#x27;ll have to test out this update and see if everything magically works
评论 #39196718 未加载
Extigyover 1 year ago
Since this is using fetch&#x2F;XHR under the hood, I guess requests from the browser are restricted only to same-origin URLs or servers responding with permissive CORS headers?
评论 #39194086 未加载
canadiantimover 1 year ago
Pyodide examples using urllib3 in browser still requires using fetch, so this still requires javascript.<p>What does this practically mean?<p>Does this ever point to a future where we can use urlib3 instead of fetch?
评论 #39192860 未加载
评论 #39193603 未加载
评论 #39192814 未加载
hoodchathamover 1 year ago
aiohttp is still work in progress but it works with a monkey patch. <a href="https:&#x2F;&#x2F;github.com&#x2F;aio-libs&#x2F;aiohttp&#x2F;pull&#x2F;7803">https:&#x2F;&#x2F;github.com&#x2F;aio-libs&#x2F;aiohttp&#x2F;pull&#x2F;7803</a>
hpeterover 1 year ago
why would you want to run python in the browser? Anyone can ELI5?
评论 #39194172 未加载
评论 #39196312 未加载
评论 #39194859 未加载
评论 #39194613 未加载
评论 #39195193 未加载
评论 #39193987 未加载