Skip to content

Response header overwrite on Android #377

Open
@zoltanlorincz

Description

@zoltanlorincz

Description:
Multiple Set-Cookie headers are valid response according to the RFC standard.

Steps to Reproduce:
Make a call to a an URL where multiple Set-Cookie headers are returned

Expected Behavior:
Further calls should be made with all cookies set.

Actual Behavior:
Only the last cookie is set.

Environment:
Library Version: all
React Native Version: all
Platform: Android

Cause:
The code in ReactNativeBlobUtilReq.java doesn't handle case when the same header received several times.
See below:

headers.putString(resp.headers().name(i), resp.headers().value(i));

The last value from Set-Cookie overwrites previous values.

private WritableMap getResponseInfo(Response resp, boolean isBlobResp) {
        WritableMap info = Arguments.createMap();
        info.putInt("status", resp.code());
        info.putString("state", "2");
        info.putString("taskId", this.taskId);
        info.putBoolean("timeout", timeout);
        WritableMap headers = Arguments.createMap();
        for (int i = 0; i < resp.headers().size(); i++) {
            headers.putString(resp.headers().name(i), resp.headers().value(i));
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions