fix EOF errors on http response with content and encoding headers #3438
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this on a response which has a Content-Encoding value, but no body will error out with EOF as we still try to decode it.
As the code and the semantics of network requests mean that we might not know if we are going to be able to read something and whether we got and EOF because of network error or because there was no body - we need to figure out if we should try to read at all.
Unfortunately
Content-Encoding: chunked
exists which makes a more general solution much harder IMO.As such the current solution is to short circuit on known status codes that do not have content. Namely all 1xx and 204 (aptly named no content) and 304 (not modified).
https://www.rfc-editor.org/rfc/rfc9110.html#section-6.4.1-8
Additionally a bare minimum tests was added reproducing what the user reported.
https://community.grafana.com/t/error-decompressing-response-body-eof-despite-http-request-returning-204/106927