-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vendor our own fetch polyfill #529
Comments
Am I right in assuming this is what you're referring to? JakeChampion/fetch#198 (comment) Are there any other polyfills out there that could be a good fit for txiki.js? Or did you want to vendor |
Yes, pretty much.
The latter, I think. I realized it's small enough that it should be easy to vendor and adapt, like remove all the support checks wich are done only once, since we know what the runtime supports. |
Actually I've started to think that a better idea would be to drop XHR completely and implement fetch straight on top of libcurl. If Node, Deno and Bun can get away with not having XHR we can too, I guess. |
Though there are some features not available in standard browser fetch that are possible with XHR. So some extensions are neeeded (nodejs e.g. has some too). |
Do you have examples of those? |
Two specifics I though of:
I think being able to get the TCP connection from the fetch api (e.g. via Connection: Keep-alive or transport upgrade) to further use it would also be useful. Though this might raise other issues/questions when it is a SSL connection. |
Good points! I don't think we can extract the connection easily, since we don't use our own TCP socket, curl does... |
It's possible to either use CURLOPT_WRITEFUNCTION / CURLOPT_OPENSOCKETFUNCTION to supply your own socket. But that has issues for SSL. Though it also seems to be possible to get the socket from curl, and prevent it from closing (CURLOPT_CLOSESOCKETFUNCTION). Though I'm not sure how both would integrate with SSL. |
Make sure |
Where can I find docs about the duplex option? I couldn't find anything on mdn. |
Example client, in code, from oven-sh/bun#7206
Deno server code on Deno Deploy that echoes to the Native Messaging extension, and public requests, i.e., from /to the client above Deno Deploy full-duplex server
The above is a single HTTP/2 connection. The closest we get to that in HTTP 1.1 is Expected result
What happens in Bun, that does not, yet, implement HTTP/2
|
Thanks! |
The fetch polyfill is vendored as of #647 I laid out the plan for the future in that PR. I'm closing this one since the initial goal (simple vendoring of the polyfill) is done, but will be coming back for the useful comments. |
Maybe try to use Workerd, Deno, or Node.js implementation of WHATWG Fetch and WHATWG Streams? |
The change needs to happen in the native implementation now, and I cannot borrow that. |
Doesn't txiki.js depend on cURL? cURL supports HTTP/2. |
Yes, but the code needs to be written to send data to the native side in chunks in case it's a ReadableStream. |
The one we use now has some problems:
Generally speaking, it's small enough that it makes sense to incorporate it and make our own changes to it.
The text was updated successfully, but these errors were encountered: