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

Android: Fetch dont't work with "deflate" encoded responses.json() #15693

Closed
DeFenceD opened this issue Aug 29, 2017 · 1 comment
Closed

Android: Fetch dont't work with "deflate" encoded responses.json() #15693

DeFenceD opened this issue Aug 29, 2017 · 1 comment
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@DeFenceD
Copy link

DeFenceD commented Aug 29, 2017

Is this a bug report?

Yes
Android use fetch dont't work with "deflate" encoded responses.json().
I copy the same fetch in browser try to it will response the right encoded json.

Environment

  1. react-native -v: 0.47.2
  2. node -v: 8.0.0
  3. npm -v: 5.3.0

Then, specify:

  • Target Platform: Android

  • Development Operating System: Windows

  • Build tools: Android SDK

Steps to Reproduce

fetch(url, {
              method: 'POST',
              headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json;charset=UTF-8',
              },
              body: JSON.stringify(options),
              compress: true,
            })
              .then((response) => {
                console.log(response);
                return response.json();
              })
              .then((result) => {
                  // result is messy code
              });

Expected Behavior

right to encoded.

Actual Behavior

return messy code

Reproducible Demo

Unhandled Promise Rejection (id: 0):
SyntaxError: Unexpected token { in JSON at position 0
at parse (<anonymous>)
    at tryCallOne (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:13773:12)
    at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:13859:15
    at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:5290:19
    at _callTimer (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:5204:7)
    at Object.callImmediatesPass (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:5432:9)
    at Object.callImmediates (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:5443:21)
    at MessageQueue.__callImmediates (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:4803:16)
    at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:4689:16
    at MessageQueue.__guard (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:4789:9)
@stale
Copy link

stale bot commented Nov 6, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. 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 Nov 6, 2017
@stale stale bot closed this as completed Nov 13, 2017
@facebook facebook locked and limited conversation to collaborators May 15, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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

1 participant