Repository navigation
fix(pushgateway): keep Content-Encoding for pushes after delete() - #870
Open
sarankumar1325 wants to merge 1 commit into
Open
sarankumar1325 wants to merge 1 commit into
sarankumar1325 wants to merge 1 commit into
Conversation
delete() removed Content-Encoding from options.headers, but options is a shallow copy, so this deleted the header from the instance's (and the caller's) headers object. Every later push()/pushAdd() then sent an uncompressed body without the gzip header. Drop the header from a copy instead. Signed-off-by: sarankumar1325 <120080287+sarankumar1325@users.noreply.github.com>
This branch has not been deployed
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.
useGateway()buildsoptionsas a shallow copy ofthis.requestOptions, and for DELETE requests it runsdelete options.headers['Content-Encoding'].options.headersis still the same object the Pushgateway was constructed with, so onedelete()call removes the header for the life of the instance (and from the caller's ownheadersobject). After that,push()andpushAdd()send plain-text bodies and noContent-Encoding: gzip, so a gateway configured for gzip silently stops compressing.The fix drops the header from a copy of the headers for DELETE only.
Tests:
should keep the gzip header for pushes after a deletecase intest/pushgatewayTest.js(runs for both registry types and both global/instance registries). It checks the DELETE has noContent-Encoding, the followingpushAdd()is gzipped with the header, and the caller's headers object is unchanged. It fails on main (4 failures) and passes with this change.npm run lint,prettier --check,tsc --project .and the fulljestsuite (655 tests) pass.