httpx support
Leaving this issue here to think about httpx support. I hope to come back to this one day and take a crack at it. I think it should be relatively simple since httpx is written in a sans-io manner which theoretically means a fetch version would be relatively simple to accomplish.
So, to fix this issue https://github.com/pyodide/pyodide/issues/4292 I'm currently trying to work on this: https://github.com/psymbio/pyodide-http and (some reference notes https://github.com/psymbio/httpx_adapter)
Check this file: https://github.com/psymbio/pyodide-http/blob/main/pyodide_http/_httpx.py
There's an issue I am stuck at: Pyodide's Request class has a timeout attribute but the httpx Request class doesn't. Can you look into the code.
@koenvo Can you have a look at this - https://github.com/psymbio/pyodide-http/tree/main/pyodide_http
Also, I'm not sure whether it's correct - any guidance will be helpful.
This is solved by using a custom transport layer and https://github.com/urllib3/urllib3/pull/3195. For the solution visit: https://github.com/encode/httpx/discussions/2994#discussioncomment-7806700.
Here is an implementation that uses run_sync to syncify pyfetch. It don't support sync APIs if the js environment doesn't support JSPI. (Note that it is very easy for a website to support JSPI through origin trial)
I wonder do you guys already did some work on using a custom layer to stream response in the sync API? I think psymbio/pyodide-http is almost there.