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

Received response with content-encoding: gzip, but failed to decode it #3849

Closed
wavenator opened this issue Feb 3, 2017 · 2 comments
Closed

Comments

@wavenator
Copy link

import requests

requests.get('http://gett.bike/')

This code raises the following exception:

ContentDecodingError: ('Received response with content-encoding: gzip, but failed to decode it.',
error('Error -3 while decompressing data: incorrect data check',))

Arch linux x64
requests==2.13.0
python=3.6.0

@Lukasa
Copy link
Member

Lukasa commented Feb 3, 2017

This seems like the server is returning data it claims is gzipped, but isn't, or is invalid somehow. curl agrees with this assessment, as you can see by doing curl -L --compressed http://gett.bike, which leads to:

curl: (23) Error while processing content unencoding: invalid block type

You can work around this for now by setting the Accept-Encoding header to identity:

import requests

requests.get('http://gett.bike/', headers={'Accept-Encoding': 'identity'})

But I strongly recommend you reach out to the server operator and get them to fix their server.

@Lukasa Lukasa closed this as completed Feb 3, 2017
@joshlsullivan
Copy link

I'm now receiving that same error. I've even switched hosting providers. Here's my output. Any ideas?



Request Method: GET
Request URL: https://sm8attachments.com/authenticate/callback/?code=1ace2d4df855a2b7e5fb6b1add0581102127cd5b&state=

Django Version: 2.1
Python Version: 3.6.6
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django_celery_results',
 'django.contrib.sites',
 'user',
 'account',
 'attachment',
 'webhook',
 'authenticate',
 'subscribe',
 'home']
Installed Middleware:
('whitenoise.middleware.WhiteNoiseMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'whitenoise.middleware.WhiteNoiseMiddleware')



Traceback:

File "/app/.heroku/python/lib/python3.6/site-packages/urllib3/response.py" in _decode
  295.                 data = self._decoder.decompress(data)

File "/app/.heroku/python/lib/python3.6/site-packages/urllib3/response.py" in decompress
  77.                 ret += self._obj.decompress(data)

During handling of the above exception (Error -3 while decompressing data: incorrect data check), another exception occurred:

File "/app/.heroku/python/lib/python3.6/site-packages/requests/models.py" in generate
  749.                     for chunk in self.raw.stream(chunk_size, decode_content=True):

File "/app/.heroku/python/lib/python3.6/site-packages/urllib3/response.py" in stream
  465.                 data = self.read(amt=amt, decode_content=decode_content)

File "/app/.heroku/python/lib/python3.6/site-packages/urllib3/response.py" in read
  437.             data = self._decode(data, decode_content, flush_decoder)

File "/app/.heroku/python/lib/python3.6/site-packages/urllib3/response.py" in _decode
  300.                 "failed to decode it." % content_encoding, e)

During handling of the above exception (('Received response with content-encoding: gzip, but failed to decode it.', error('Error -3 while decompressing data: incorrect data check',))), another exception occurred:

File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  126.                 response = self.process_exception_by_middleware(e, request)

File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  124.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/app/.heroku/python/lib/python3.6/site-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/app/.heroku/python/lib/python3.6/site-packages/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/app/authenticate/views.py" in get
  58.         for vendor in get_vendors(r['access_token']):

File "/app/authenticate/views.py" in get_vendors
  34.     vendors = requests.get(url, headers=headers).json()

File "/app/.heroku/python/lib/python3.6/site-packages/requests/api.py" in get
  72.     return request('get', url, params=params, **kwargs)

File "/app/.heroku/python/lib/python3.6/site-packages/requests/api.py" in request
  58.         return session.request(method=method, url=url, **kwargs)

File "/app/.heroku/python/lib/python3.6/site-packages/requests/sessions.py" in request
  512.         resp = self.send(prep, **send_kwargs)

File "/app/.heroku/python/lib/python3.6/site-packages/requests/sessions.py" in send
  662.             r.content

File "/app/.heroku/python/lib/python3.6/site-packages/requests/models.py" in content
  827.                 self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''

File "/app/.heroku/python/lib/python3.6/site-packages/requests/models.py" in generate
  754.                     raise ContentDecodingError(e)

Exception Type: ContentDecodingError at /authenticate/callback/
Exception Value: ('Received response with content-encoding: gzip, but failed to decode it.', error('Error -3 while decompressing data: incorrect data check',))```

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants