Adding the provision of redirecting HTTP requests to HTTPS#675
Open
ShubhamGupta29 wants to merge 2 commits into
Open
Adding the provision of redirecting HTTP requests to HTTPS#675ShubhamGupta29 wants to merge 2 commits into
ShubhamGupta29 wants to merge 2 commits into
Conversation
loganrosen
suggested changes
Apr 9, 2020
| * @return Return the port of the of the hostAddress if exists else return INVALID_PORT | ||
| */ | ||
| private String getPortFromHostAddress(String hostAddress) { | ||
| String patterForPort = "(.+):([\\d]{1,5})"; |
Contributor
Author
There was a problem hiding this comment.
After using Guava's HostAndPort.fromString() there was no need of the method so removed the respective method.
Comment on lines
+129
to
+141
| /** | ||
| * | ||
| * @param hostAddress The hostAddress string which will be of format "elephant.abc.com:8080" | ||
| * @return Return the port of the of the hostAddress if exists else return INVALID_PORT | ||
| */ | ||
| private String getPortFromHostAddress(String hostAddress) { | ||
| String patterForPort = "(.+):([\\d]{1,5})"; | ||
| Matcher matcher = Pattern.compile(patterForPort).matcher(hostAddress); | ||
| if (matcher.find()) { | ||
| return matcher.group(2); | ||
| } | ||
| return INVALID_PORT; | ||
| } |
There was a problem hiding this comment.
You might want to consider leveraging Guava's HostAndPort.fromString() instead of manually implementing this logic. I also don't think this regular expression will work if it's a bare IPv6 address.
Contributor
Author
There was a problem hiding this comment.
Big thanks Logan, I was looking for such a utility method and couldn't find it so implemented a crude one. Thanks for the review and for reporting this issue.
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.
DESCRIPTION
In this PR changes are done to redirect HTTP requests to HTTPS-enabled endpoints if Dr.Elephant has HTTPS enabled. This is achieved by checking the port of every request and if the port is the same as that of HTTP_PORT(defined in elephant.conf or 8080 by default) then redirect the request to the HTTPS-enabled port if exists.
HOW THESE CHANGES ARE TESTED
Tested these changes on the local and EI machines both. In this testing confirmed if the HTTPS requests are getting redirected to HTTPs endpoints or not.