address pr comments, no need to modify host and have default proto be http
@@ -60,23 +60,12 @@ public final class LocalUserService extends AbstractLocalRpcService
}
String host = req.getHeader("Host");
String forwardedProto = req.getHeader("X-Forwarded-Proto");
- if (host == null || forwardedProto == null) {
- throw new RuntimeException(loginURLError);
+ if (forwardedProto == null) {
+ forwardedProto = "http";
}
- String[] hostPieces = host.split(":");
- if (hostPieces.length > 1) {
- String serverPort = "";
- String httpsPort = req.getHeader("X-Redirect-Https-Port");
- String httpPort = req.getHeader("X-Redirect-Http-Port");
- if (httpsPort == null || httpPort == null) {
+ if (host == null) {
throw new RuntimeException(loginURLError);
}
- serverPort = ":";
- serverPort += (forwardedProto.equals("https"))
- ? (httpsPort)
- : (httpPort);
- host = hostPieces[0] + serverPort;
- }
// Construct the url.
destinationUrl = forwardedProto + "://" + host + destinationUrl;
@@ -102,23 +91,12 @@ public final class LocalUserService extends AbstractLocalRpcService
String host = req.getHeader("Host");
String forwardedProto = req.getHeader("X-Forwarded-Proto");
- if (host == null || forwardedProto == null) {
- throw new RuntimeException(logoutURLError);
+ if (forwardedProto == null) {
+ forwardedProto = "http";
}
- String[] hostPieces = host.split(":");
- if (hostPieces.length > 1) {
- String serverPort = "";
- String httpsPort = req.getHeader("X-Redirect-Https-Port");
- String httpPort = req.getHeader("X-Redirect-Http-Port");
- if (httpsPort == null || httpPort == null) {
+ if (host == null) {
throw new RuntimeException(loginURLError);
}
- serverPort = ":";
- serverPort += (forwardedProto.equals("https"))
- ? (httpsPort)
- : (httpPort);
- host = hostPieces[0] + serverPort;
- }
// Construct the url.
String destinationUrl = forwardedProto + "://" + host;
