10

I am using python with requests module to fetch data from api with a json feed. When I include the request for gzip as the encoding I am not seeing any change. Am I implementing it the wrong way here?

my_headers = {'accept-encoding':'gzip'}
response = requests.get(url, headers=my_headers)
print(response.headers)
print(len(response.content))

The response headers always come back with

'Content-Encoding': 'gzip'

but this happens with or without the inclusion of my request headers, the length and load times do not change either

1 Answer 1

14

Requests: HTTP for Humans - Binary Response Content

gzip and deflate transfer-encodings are automatically decoded for you.

Sign up to request clarification or add additional context in comments.

1 Comment

Updated link: requests.readthedocs.io/en/latest/user/quickstart/… (cannot edit the original answer)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.