-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
cURL-like API for XHR request as a JavaScript library #3270
Comments
Adding cURL support sounds ok, but I am not sure if we want to replace or deprecate the current |
I'm totally fine with that. Since there is a code base using
|
This issue has been automatically marked as stale because there has been no activity in the past 2 years. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant. |
I would love to see this implemented in the future |
Does the existing If you are you look for an API to use from JS, then I don't see how this has anything to do with emscripten? libcurl is native library but if you just want a JS re-implemenation of libcurl then that doesn't really have any relation to emscripten as far as I can tell. Emscripten is about compiling native code for the web and libcurl (that actual native version probably don't itself compile for the web, but require come kind of re-implemenation on top of web apis (like XHR)). |
It’s been a while since I opened this issue, but the feature request still makes sense to me. If you use OpenGL in your native code, Emscripten takes care of binding calls to WebGL. The idea is to do the same for libcurl and XHR. It would avoid conditional blocks to use either the native or the Emscripten-specific API. While not strictly necessary, I think this fits with the Emscripten philosophy. On my end, I’m not using Emscripten these days so I don’t really need this anymore, but it would be a good addition to the project. |
True, I can see that exposing a native libcurl API, implemented in JS might be useful. I'm not sure much of the libcurl API surface is possible to implement without actual TCP/UDP under the hood. Maybe enough? In any case, I will re-open with "Help Wanted". |
Yes, for sure there are cURL APIs that can’t be implemented in XHR or fetch, just like there are OpenGL APIs that can’t be implemented in WebGL. It’s still very useful to have automagic bindings for the 90% use cases covered by both platforms. |
I'm having trouble implementing emscripten_wget into my code at https://github.com/jrynkiew/WebOS at WebOS/src/cpp/WebOS/WebOS.cpp using static callback functions (I know I'm doing something wrong), but I have these functions wrapped in ifdef(emscripten) for WASM. For Linux or Windows I use a standard cURL call, and it compiles successfully. It would simply be much much easier to implement cross platform compatible code if these call styles were kept the same for native / emscripten usage, even if the functionality was greatly reduced. Best Regards, |
Actually I solved my problem, never occurred to me to use emscripten fetch the same way as cURL :P I have all my problems sorted, now just some interface errors. First define the variables needed for cURL and a string buffer for use with emscripten WASM or Windows/Linux binaries (determined at build time)
Then the implementation
and the callback functions for cURL and emscripten_fetch
I don't really know what I'm doing with fetch->totalBytes in the emscripten callback, so I just used it the same way cURL does it, but it seems to work nonetheless. All the code samples were copied from the curl and emscripten_fetch documentation examples. I'm not an expert in emscripten, nor C++/C for that matter, but I got it working :) Having said all that, I still would love to see this implemented as a native library in emscripten :) |
Amen |
Is there any news on this? |
There is no direct emulation of libcurl in emscripten today, and no plans to add it. If anyone wanted to contribute a libcurl port to |
Following up on #3016.
The cURL API is well tested and well known. I'm not sure we could implement it to match all cURL features, but the cURL API definitely covers the XHR browser API, effectively replacing
emscripten_wget_*
.Any good soul and/or lazy intern in a company using Emscripten that would be willing to implement that?
The text was updated successfully, but these errors were encountered: