在 android 中使用 ReactNative 时 axios 无法支持 gzip

axios could not support gzip when use ReactNative in android

"axios": "^0.16.2"

"react":“16.0.0-alpha.12”

"react-native": "^0.47.1"

在发送请求之前,我设置了一个 header axios.defaults.headers.common['Accept-Encoding'] = 'gzip, deflate'。我得到了一些未知的响应(实际上是 JSON),它在 iOS.

中工作正常

解决方案是不要向 axios 添加 HEADER。 RN 支持 gzip 作为 OOTB。 这是 nginx 上的 POC 结果,

1、第一行是一个curl调用,响应是56987

2,第二行是一个带有header -H "Accept-Encoding:gzip"的curl调用,响应是3629

3、第三行是App发送的请求,响应大小为3641