Skip to content

Fetch API POST request bug ? #5865

Closed
Closed

Description

@ijean

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

Activity

  1. cmdcolin commented on Jan 8, 2018

    @cmdcolin

    Just wanted to add a +1 to this was hoping to use requestHeaders also!

  2. added 2 commits that reference this issue on Feb 6, 2018
    510b83d
    794b09a
  3. added a commit that references this issue on Jul 10, 2018
  4. kripken commented on Jul 10, 2018

    @kripken
    Member

    This may have been fixed by #6514 - please check.

  5. stale commented on Sep 18, 2019

    @stale

    This issue has been automatically marked as stale because there has been no activity in the past year. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions