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

Axios includes br in Accept-Encoding even if transparent decompression is not supported #5258

Closed
lucaswerkmeister opened this issue Nov 12, 2022 · 2 comments

Comments

@lucaswerkmeister
Copy link

Describe the bug

Axios has optional support for transparently decompressing brotli-encoded responses, depending on whether brotli support is available in the runtime.

const isBrotliSupported = utils.isFunction(zlib.createBrotliDecompress);
        case 'br':
          if (isBrotliSupported) {
            streams.push(zlib.createBrotliDecompress());
            delete res.headers['content-encoding'];
          }

However, it unconditionally includes br in the Accept-Encoding header it sets (if the header wasn’t specified by the library user), regardless of whether the runtime supports brotli or not.

    headers.set('Accept-Encoding', 'gzip, deflate, br', false);

So if brotli support isn’t available, and the server decides to encode the response using brotli (which it’s allowed to, based on the header axios added), then the library user will be left with a response they can’t decode, even though they don’t asked for brotli encoding.

To Reproduce

No response

Code snippet

No response

Expected behavior

No response

Axios Version

1.2.0-alpha.1

Adapter Version

http

Browser

No response

Browser Version

No response

Node.js Version

No response

OS

No response

Additional Library Versions

No response

Additional context/Screenshots

No response

@mcuelenaere
Copy link

Isn't this fixed since #5306?

@lucaswerkmeister
Copy link
Author

True, I forgot to close this when I closed #5259.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants