|
|
|
|
@ -24,7 +24,6 @@ import java.util.concurrent.atomic.AtomicLong;
@@ -24,7 +24,6 @@ import java.util.concurrent.atomic.AtomicLong;
|
|
|
|
|
import javax.net.ssl.SSLSession; |
|
|
|
|
|
|
|
|
|
import io.netty.channel.Channel; |
|
|
|
|
import io.netty.handler.codec.http.HttpHeaderNames; |
|
|
|
|
import io.netty.handler.codec.http.cookie.Cookie; |
|
|
|
|
import io.netty.handler.ssl.SslHandler; |
|
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
|
@ -79,36 +78,11 @@ class ReactorServerHttpRequest extends AbstractServerHttpRequest {
@@ -79,36 +78,11 @@ class ReactorServerHttpRequest extends AbstractServerHttpRequest {
|
|
|
|
|
|
|
|
|
|
private static URI resolveBaseUrl(HttpServerRequest request) throws URISyntaxException { |
|
|
|
|
String scheme = getScheme(request); |
|
|
|
|
|
|
|
|
|
InetSocketAddress hostAddress = request.hostAddress(); |
|
|
|
|
if (hostAddress != null) { |
|
|
|
|
return new URI(scheme, null, hostAddress.getHostString(), hostAddress.getPort(), null, null, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
String header = request.requestHeaders().get(HttpHeaderNames.HOST); |
|
|
|
|
if (header != null) { |
|
|
|
|
final int portIndex; |
|
|
|
|
if (header.startsWith("[")) { |
|
|
|
|
portIndex = header.indexOf(':', header.indexOf(']')); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
portIndex = header.indexOf(':'); |
|
|
|
|
} |
|
|
|
|
if (portIndex != -1) { |
|
|
|
|
try { |
|
|
|
|
return new URI(scheme, null, header.substring(0, portIndex), |
|
|
|
|
Integer.parseInt(header, portIndex + 1, header.length(), 10), null, null, null); |
|
|
|
|
} |
|
|
|
|
catch (NumberFormatException ex) { |
|
|
|
|
throw new URISyntaxException(header, "Unable to parse port", portIndex); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
return new URI(scheme, header, null, null); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
throw new IllegalStateException("Neither local hostAddress nor HOST header available"); |
|
|
|
|
int port = request.hostPort(); |
|
|
|
|
return ((scheme.equals("http") || scheme.equals("ws")) && (port != 80)) || |
|
|
|
|
((scheme.equals("https") || scheme.equals("wss")) && (port != 443)) ? |
|
|
|
|
new URI(scheme, null, request.hostName(), port, null, null, null) : |
|
|
|
|
new URI(scheme, request.hostName(), null, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static String getScheme(HttpServerRequest request) { |
|
|
|
|
|