Skip to content

Fetch only brings latest value of same-name headers on Android, works on iOS. #23005

Closed
@Return-1

Description

This is a long standing bug reported here #18837. Unfortunately #18837 became stale but i can confirm the problem persists.

Environment

React Native Environment Info:

    System:
      OS: macOS Sierra 10.12.6
      CPU: (4) x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz
      Memory: 31.03 MB / 8.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.15.0 - ~/.nvm/versions/node/v10.15.0/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v10.15.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 11.2, macOS 10.13, tvOS 11.2, watchOS 4.2
      Android SDK:
        API Levels: 23, 24, 25, 26, 27, 28
        Build Tools: 23.0.1, 25.0.2, 26.0.3, 27.0.2, 27.0.3, 28.0.0
        System Images: android-28 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.1 AI-173.4819257
      Xcode: 9.2/9C40b - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.3 => 16.6.3
      react-native: 0.57.8 => 0.57.8

Description

This is a long standing bug reported here #18837 and in different forms in many other places that i havent kept track of, will append later on with an edit.

The issue is that in the presence of multiple headers with the same name as is common with e.g Set-Cookie the android version of fetch will always only ever keep the latest cookie.

So in practice if one wants to get more than one cookies at a time from the response they received they cant do it. There is a workaround which also described on #18837 and essentially introduces the following changes to MainApplication.java:

ReadableNativeArray.setUseNativeAccessor(true);
ReadableNativeMap.setUseNativeAccessor(true);

However I am very uncertain as to what side-effects it might be causing elsewhere. Right now this is what im using but not feeling secure about it.

Reproducible Demo

Reproduction is identical to #18837 found here Reproduction can also be found in 18837 which i run and can confirm.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions