itinance / itinance/react-native-fs

Add option to forward headers on redirect

Open
#1,119 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
5k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

# Feature Request

Today, when following redirects on Android, the headers passed to `downloadFile()` method are not forwarded on the second request that follows the redirect.
I understand that, by design, most http clients don't forward the headers be default for security reasons. My suggestion is to add a configuration parameter to allow the developer to allow this to happen.

## Why it is needed

When dealing with URLs that require an authorisation header this makes the request ending up as Unauthorised.

## Possible implementation

Set the initial request properties on the connection that follows the redirect if a new parameter (e.g. `forwardHeadersOnRedirect`) is true:
https://github.com/itinance/react-native-fs/blob/master/android/src/main/java/com/rnfs/Downloader.java#L79

### Code sample

```
RNFS.downloadFile({ forwardHeadersOnRedirect: true, ... })
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.