-
Notifications
You must be signed in to change notification settings - Fork 801
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
Implement redirect handler option. #622
Merged
csmarchbanks
merged 7 commits into
prometheus:master
from
espears1:espears1/issue-131-redirect-handler
Feb 11, 2021
Merged
Implement redirect handler option. #622
csmarchbanks
merged 7 commits into
prometheus:master
from
espears1:espears1/issue-131-redirect-handler
Feb 11, 2021
Conversation
This file contains 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
Signed-off-by: Ely Spears <espears@squarespace.com>
espears1
force-pushed
the
espears1/issue-131-redirect-handler
branch
from
February 8, 2021 18:12
1b75532
to
4613dfa
Compare
Signed-off-by: Ely Spears <espears@squarespace.com>
espears1
force-pushed
the
espears1/issue-131-redirect-handler
branch
from
February 8, 2021 18:28
c31af42
to
67e99ff
Compare
Signed-off-by: Ely Spears <espears@squarespace.com>
csmarchbanks
reviewed
Feb 9, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Generally this is looking good, just a couple of questions to begin with.
Signed-off-by: Ely Spears <espears@squarespace.com>
Signed-off-by: Ely Spears <espears@squarespace.com>
Signed-off-by: Ely Spears <espears@squarespace.com>
Signed-off-by: Ely Spears <espears@squarespace.com>
csmarchbanks
approved these changes
Feb 11, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good to me!
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 fixes #131 and a significant amount of content is discussed in that issue.
This PR adds a new redirect handler utility class that deliberately forwards an unmodified request to the
Location
header provided by a redirect, while preserving the method, headers and data of the original request. As discussed in comments of the PR, HTTP RFC 2616 requires explicit user approval for redirects in certain situations that may alter the meaning or effect of the request. Given this, the defaultHTTPRedirectHandler
inurllib
does not honor redirects forPUT
and does not preserve all headers and data.In the case of Prometheus, many users will have some type of in-house "private" deployment of a Prometheus pushgateway server, and e.g. in a deployment infrastructure like Kubernetes where the ultimate IP-based host address could change often, there may be a need for a purely cosmetic redirect that fronts this host address with an easier static URL. In that case, the user would like to "opt in" to trusted pass-through redirects for all method types (including PUT).
This PR provides
passthrough_redirect_handler
to support this specific redirect option. Use of this special redirect handler would constitute the user's explicit approval for RFC2616.Additionally, this PR adds a new "redirect" HTTPD server to the unit tests for the pushgateway, in order to simulate a real redirect during testing and confirm it is handled as expected. I've locally validated all testing and flake8 instructions - and will work to resolve any requested changes or build issues.