Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Body request gzip behaviour inconsistent between ios and android #22921

Closed
robinclaes opened this issue Jan 9, 2019 · 4 comments
Closed

Body request gzip behaviour inconsistent between ios and android #22921

robinclaes opened this issue Jan 9, 2019 · 4 comments
Labels
Bug Platform: Android Android applications. Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@robinclaes
Copy link

robinclaes commented Jan 9, 2019

Environment

React Native Environment Info:
    System:
      OS: macOS 10.14.2
      CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
      Memory: 72.56 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
      Yarn: 1.12.3 - ~/.yarn/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v10.13.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 24, 26, 27, 28
        Build Tools: 27.0.3, 28.0.3
        System Images: android-28 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.5.1 => 16.5.1 
      react-native: ^0.57.0 => 0.57.7 
    npmGlobalPackages:
      react-native-cli: 2.0.1
      @qompium/react-native-fibricheck-sdk: 0.3.3

Description

When trying to gzip a request body (before a POST request), this behaviour is inconsistent across iOS and Android.

iOS: Manually gzip the body (in my case using pako) and add the Content-Encoding: gzip header.

Android: Add the Content-encoding: gzip header and the underlying okHttp client (Android's built-in http client?) will do the gzipping for you it seems.

*When react-native-debugger is open, manually gzipping the body is required too, but I guess this is because the requests go through Chrome's http client and not the device's http client?

Reproducible Demo

await axios({
        data: body,
        transformRequest: axios.defaults.transformRequest.concat((body, headers) => {
          if (typeof body === 'string' && body.length > 1024) {
            headers['Content-Encoding'] = 'gzip';
            return Platform.switch({
              ios: pako.gzip(body), // manually gzip
              android: body, // okHttp will do the rest if the header is set
            });
          }
        }),
        method: 'POST',
        url: '...',
});
@robinclaes robinclaes changed the title Body request gzip behaviour inconsistent between ios and android? Body request gzip behaviour inconsistent between ios and android Jan 9, 2019
@react-native-bot react-native-bot added Platform: Android Android applications. Platform: iOS iOS applications. labels Jan 9, 2019
@hramos hramos removed the Bug Report label Feb 6, 2019
@orta
Copy link
Contributor

orta commented Mar 19, 2019

Is the answer for this to add support for content-encoding: 'gzip' to iOS, so that it's consistent?

@cpojer
Copy link
Contributor

cpojer commented Mar 26, 2019

@robinclaes would you be able to send a Pull Request to align this behavior?

@stale
Copy link

stale bot commented Aug 4, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 4, 2019
@stale
Copy link

stale bot commented Aug 11, 2019

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Aug 11, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Aug 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

6 participants