-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Description
Hi All
I somehow found that the synchronous API is not working properly.
I used the following example source code from the API document.
#include <stdio.h>
#include <string.h>
#include <emscripten/fetch.h>
int main() {
emscripten_fetch_attr_t attr;
emscripten_fetch_attr_init(&attr);
strcpy(attr.requestMethod, "GET");
attr.attributes = EMSCRIPTEN_FETCH_LOAD_TO_MEMORY | EMSCRIPTEN_FETCH_SYNCHRONOUS;
emscripten_fetch_t *fetch = emscripten_fetch(&attr, "test.txt"); // Blocks here until the operation is complete.
if (fetch->status == 200) {
printf("Finished downloading %llu bytes from URL %s.\n", fetch->numBytes, fetch->url);
// The data is now available at fetch->data[0] through fetch->data[fetch->numBytes-1];
} else {
printf("Downloading %s failed, HTTP failure status code: %d.\n", fetch->url, fetch->status);
}
emscripten_fetch_close(fetch);
}I then compiled the source code using
emcc example.cc -s FETCH=1 --proxy-to-worker -o example.html
Then I started the emrun http server, which allowed me to load the example.html in my firefox browser (Ubuntu 19.04) through http://localhost:6931/example.html
Somehow the console outputted
running code in a webworker
Downloading test.txt failed, HTTP failure status code: 0.
I double checked that http://localhost:6901/test.txt exists and the link flag contains --proxy-to-worker.
My emcc version is 1.38.31. (Also tried the upstream one 1.38.34)
Anyone could enlighten me?
Cheers
Elliott
Metadata
Metadata
Assignees
Labels
No labels