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

Fix HTTP::Client implicit compression with retry #12536

Conversation

straight-shoota
Copy link
Member

This patch fixes the retry mechanism in HTTP::Client (which reconnects after a server hangup) forgetting whether the request had an Accept-Encoding header. The client alters the request headers by adding its own Accept-Encoding header (if missing) and subsequently implicitly decompresses the response body.

The fix is actually quite simple: The exec method needs to remember between the first send and the second (the retry) whether to use implicit compression.
Most of the changes are basically boilerplate to pass the information through to the nested methods.

Fixes #11354

@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:networking labels Sep 28, 2022
Copy link
Member

@beta-ziliani beta-ziliani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@beta-ziliani beta-ziliani added this to the 1.6.0 milestone Sep 29, 2022
@straight-shoota straight-shoota merged commit 12a9b5f into crystal-lang:master Sep 30, 2022
@straight-shoota straight-shoota deleted the fix/http_client-implicit_compression branch September 30, 2022 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:networking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP::Client repeated usage results in compressed response body, but only on server keep alive timeout
2 participants