facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.28k stars 24.35k forks source link

Getting cookies from Http requests: Headers.getSetCookie() #47049

Closed LinusU closed 1 hour ago

LinusU commented 1 month ago

Description

Currently, it's not possible to get the Set-Cookie headers from http requests, specifically via headers.getSetCookie().

I've started work on this:

  1. https://github.com/JakeChampion/fetch/pull/1472
  2. https://github.com/facebook/react-native/compare/main...LinusU:react-native:get-set-cookie

Plan for next steps:

  1. Make sure changes to Android part works
  2. Also update iOS to send array instead of map
  3. Update JavaScript part to receive array instead of map
  4. Test that this works

If anyone wants to help out, feel free to!

Steps to reproduce

Snack: https://snack.expo.dev/@linusu/authentic-yellow-soda

Relevant code:

const response = await fetch('https://httpbin.org/cookies/set?x=x&y=y')
const cookies = response.headers.getSetCookie()

// cookies should be ["x=x", "y=y"]

React Native Version

0.74.5

Affected Platforms

Runtime - Android, Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 15.0.1
  CPU: (11) arm64 Apple M3 Pro
  Memory: 1001.42 MB / 36.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.16.0
    path: ~/Library/Caches/fnm_multishells/42255_1729074242539/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.8.1
    path: ~/Library/Caches/fnm_multishells/42255_1729074242539/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.0
      - iOS 18.0
      - macOS 15.0
      - tvOS 18.0
      - visionOS 2.0
      - watchOS 11.0
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.21829.142.2421.12409432
  Xcode:
    version: 16.0/16A242d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: javac 23
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.74.5
    wanted: 0.74.5
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

TypeError: response.headers.getSetCookie is not a function (it is undefined)

Reproducer

https://snack.expo.dev/@linusu/authentic-yellow-soda

Screenshots and Videos

No response

react-native-bot commented 1 month ago
:warning: Add or Reformat Version Info
:information_source: We could not find or parse the version number of React Native in your issue report. Please use the template, and report your version including major, minor, and patch numbers - e.g. 0.70.2
react-native-bot commented 1 month ago
:warning: Add or Reformat Version Info
:information_source: We could not find or parse the version number of React Native in your issue report. Please use the template, and report your version including major, minor, and patch numbers - e.g. 0.70.2
react-native-bot commented 1 week ago

This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.

react-native-bot commented 1 hour ago

This issue was closed because it has been stalled for 7 days with no activity.