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

Add integration test to test for accept-encoding: gzip #883

Merged
merged 2 commits into from
Aug 21, 2024

Conversation

thomasht86
Copy link
Collaborator

I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.

Ref #872.

It turns out both requests and httpx adds a default header with Accept-Encoding: gzip, deflate.
The Vespa container also replies with content-encoding: gzip

The behavior can be verified with

import requests
import httpx

# Using requests
requests_response = requests.get('https://httpbin.org')
print("Requests - Accept-Encoding header:", requests_response.request.headers.get('Accept-Encoding'))

# Using httpx
httpx_response = httpx.get('https://httpbin.org')
print("HTTPX - Accept-Encoding header:", httpx_response.request.headers.get('Accept-Encoding'))

They will also be decompressed automatically.
See:

Any gzip and deflate HTTP response encodings will automatically be decoded for you.

Requests automatically decompresses gzip-encoded responses, and does its best to decode response content to unicode when possible.

This PR adds integration tests to test for this.

@thomasht86 thomasht86 requested a review from jobergum August 21, 2024 10:00
@jobergum jobergum merged commit f79700e into master Aug 21, 2024
46 checks passed
@jobergum jobergum deleted the thomasht86/add-compression-support branch August 21, 2024 11:46
@jobergum
Copy link

Thanks for investigating this

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 this pull request may close these issues.

2 participants