-
Notifications
You must be signed in to change notification settings - Fork 859
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
Adding the provision of redirecting HTTP requests to HTTPS #675
base: tuning_20190221
Are you sure you want to change the base?
Adding the provision of redirecting HTTP requests to HTTPS #675
Conversation
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 for implementing this!
app/Global.java
Outdated
* @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})"; |
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.
s/patter/pattern/
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.
After using Guava's HostAndPort.fromString() there was no need of the method so removed the respective method.
app/Global.java
Outdated
/** | ||
* | ||
* @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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
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.
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.
LGTM
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.