fix(decompress): skip HEAD responses#5564
Merged
Merged
Conversation
Signed-off-by: Ram-blip <ramcruze2000@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5564 +/- ##
=======================================
Coverage 93.44% 93.44%
=======================================
Files 110 110
Lines 37434 37438 +4
=======================================
+ Hits 34979 34984 +5
+ Misses 2455 2454 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This relates to...
interceptors.decompress()currently attempts to initialize a decoder forHEADresponses when the server includes a supportedContent-Encoding.Because a valid
HEADresponse contains no response body, the decoder receives no compressed data andresponse.body.text()rejects with:The interceptor also removes
Content-EncodingandContent-Length, even though those headers describe the correspondingGETrepresentation and are valid metadata on aHEADresponse.Rationale
HTTP
HEADresponses must not include response content, but their representation headers describe the response that would have been returned for a correspondingGET.Undici’s Fetch implementation already skips response decoding for
HEAD. The decompression interceptor should do the same rather than creating an empty decoder and removing representation metadata.Changes
Features
N/A
Bug Fixes
HEADrequests.Content-EncodingandContent-Lengthon encodedHEADresponses.Z_BUF_ERROR.Client.compose(interceptors.decompress()).Breaking Changes and Deprecations
None.
Testing
Status