itinance / itinance/react-native-fs

Content-Length http header might be missing

Open
#1,185 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

This line https://github.com/itinance/react-native-fs/blob/64aa755cc1d37f59fa205bf2d52dd71a7d691504/windows/RNFS/RNFSManager.cpp#L947 assumes that there's always a `content-length` header returned as part of a http request, but if the client has issued an `Accept-Encoding: gzip, deflate, br` header, then the content-length header will be missing from the server, because the server has entered streaming mode, returning an on-the-fly compressed response, where the content-length can't be known in advance.

The lack of the `content-length` causes the library to crash in these cases.

Here's a curl session where the content-length is returned:

```
curl 'https://placehold.co/600x400/EEE/31343C' -v -o /dev/null 2>&1 | grep -i content-length
$ < Content-Length: 6010
```

and here's the same request when the client says it can take a compressed response:

```
curl --http1.1 'https://placehold.co/600x400/EEE/31343C' -v -o /dev/null -H 'Accept-Encoding: gzip, deflate, br' 2>&1 | grep -i content-length
```

no content-length is present

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.