Skip to content

"unexpected end of file" with gzipped 304 HTTP response #3055

@kelson42

Description

@kelson42

Describe the bug

When request has Content-Encoding: gzip|deflate|compress header and response has 304 Not Modified status code the following error is thrown: unexpected end of file.

To Reproduce

axios({
    url: 'https://upload.wikimedia.org/wikipedia/commons/4/47/Sound-icon.svg',
    headers: {
        'accept-encoding': 'gzip, deflate',
        'If-None-Match': 'c523b36f867debdf152790574ec4989b'
    },
    validateStatus(status) { return (status >= 200 && status < 300) || status === 304 }
})
  .then(function (response) { console.log('OK') })
  .catch(function (error) { console.error(`NOK: ${error}`) });

I get:

NOK: Error: unexpected end of file

Expected behavior

OK

Environment

  • Axios: 0.19.2
  • Node.js: v12.18.1

Additional context/Screenshots

Basically the same like #1658 but with HTTP 304 Not Modified
Pretty similar to #3036 as well

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions