react-native-fs icon indicating copy to clipboard operation
react-native-fs copied to clipboard

Add option to forward headers on redirect

Open hugo-advizr opened this issue 3 years ago • 0 comments

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, ... })

hugo-advizr avatar Jul 29 '22 10:07 hugo-advizr