Open eschoeffler-google opened 2 months ago
Nice idea. Its kind of shame that when we added emscripten_async_wget2
we didn't use a struct to hold the new arguments. Adding another agument at this point will require something like emscripten_async_wget3
.. which is kind of a sad place to end up.
See af4716bb662651c26fdbe5ca1fb1e6a4e8384301
Aside from the ergonomics of adding another overload, one tricky thing is that I believe fetchSettings is an arbitrary JS map so finding a flexible enough implementation in the C API might be tricky.
Currently, emscripten_async_wget and its sibling functions emscripten_async_wget_data, emscripten_async_wget2 and emscripten_async_wget2_data do not have a parameter that dynamically sets fetchSettings. Instead fetch settings are either pulled from a Module['fetchSettings'] global constant or, if that is not provided, a default is used.
In at least one fetchSettings case (credentials), it can be necessary to use a different value for different URLs. If credentials = include, that causes CORS errors fetching from cross domains that don't support cross domain credentials. If credentials = same-origin, then credentials won't be shared with cross domains that do support cross domain credentials.
One workaround is to mutate Module['fetchSettings'] just prior to calling emscriptent_async_wget and then reset it just after to get the same effect. However, this is less ergonomic and obvious than a fetchSettings parameter would be.