Hi,
I'm trying to use the Fetch API to POST some data to a LAMP server. I took your Fetch API example from the documentation and changed the requestMethod and filled the data array. I think something is wrong with attr.requestHeaders somewhere because, on the server side I get nothing in the $_POST array. Here is the modified code:
int main() {
emscripten_fetch_attr_t attr;
emscripten_fetch_attr_init(&attr);
strcpy(attr.requestMethod, "POST");
attr.attributes = EMSCRIPTEN_FETCH_LOAD_TO_MEMORY;
attr.onsuccess = downloadSucceeded;
attr.onerror = downloadFailed;
const char * headers[] = {"Content-Type", "application/x-www-form-urlencoded", 0};
attr.requestHeaders = headers;
attr.requestData = "key1=var1&key2=var2&key3=var3";
attr.requestDataSize = strlen(attr.requestData);
emscripten_fetch(&attr, "http://blahblah.com/test.php");
return 0;
}
Maybe the problem is here https://github.com/kripken/emscripten/blob/incoming/system/lib/fetch/emscripten_fetch.cpp#L78 ? It seems that the attr.requestHeaders are simply ignored.
Thanks
Hi,
I'm trying to use the Fetch API to POST some data to a LAMP server. I took your Fetch API example from the documentation and changed the requestMethod and filled the data array. I think something is wrong with attr.requestHeaders somewhere because, on the server side I get nothing in the $_POST array. Here is the modified code:
Maybe the problem is here https://github.com/kripken/emscripten/blob/incoming/system/lib/fetch/emscripten_fetch.cpp#L78 ? It seems that the attr.requestHeaders are simply ignored.
Thanks