diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpURI.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpURI.java index 5da5dd45120..d5cc83519cf 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpURI.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpURI.java @@ -119,6 +119,7 @@ public class HttpURI public HttpURI(HttpURI uri) { this(uri._scheme,uri._host,uri._port,uri._path,uri._param,uri._query,uri._fragment); + _uri=uri._uri; } /* ------------------------------------------------------------ */ diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/MetaData.java b/jetty-http/src/main/java/org/eclipse/jetty/http/MetaData.java index b4038cbdb95..43bc07d794a 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/MetaData.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/MetaData.java @@ -158,7 +158,6 @@ public class MetaData implements Iterable this(request.getMethod(),new HttpURI(request.getURI()), request.getVersion(), new HttpFields(request.getFields()), request.getContentLength()); } - // TODO MetaData should be immuttable!!! public void recycle() { super.recycle(); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractNCSARequestLog.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractNCSARequestLog.java index ab46bd52174..036b5142ad5 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractNCSARequestLog.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractNCSARequestLog.java @@ -142,7 +142,7 @@ public abstract class AbstractNCSARequestLog extends AbstractLifeCycle implement buf.append("] \""); append(buf,request.getMethod()); buf.append(' '); - append(buf,request.getHttpURI().toString()); + append(buf,request.getOriginalURI()); buf.append(' '); append(buf,request.getProtocol()); buf.append("\" "); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java index fbc42e0708b..44342e23749 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java @@ -161,6 +161,7 @@ public class Request implements HttpServletRequest private final HttpInput _input; private MetaData.Request _metadata; + private String _originalURI; private String _contextPath; private String _servletPath; @@ -1578,6 +1579,14 @@ public class Request implements HttpServletRequest return _metadata==null?null:_metadata.getURI(); } + /* ------------------------------------------------------------ */ + /** + * @return Returns the original uri passed in metadata before customization/rewrite + */ + public String getOriginalURI() + { + return _originalURI; + } /* ------------------------------------------------------------ */ /** * @param uri the URI to set @@ -1747,6 +1756,7 @@ public class Request implements HttpServletRequest public void setMetaData(org.eclipse.jetty.http.MetaData.Request request) { _metadata=request; + _originalURI=_metadata.getURIString(); setMethod(request.getMethod()); HttpURI uri = request.getURI(); @@ -1803,6 +1813,7 @@ public class Request implements HttpServletRequest protected void recycle() { _metadata=null; + _originalURI=null; if (_context != null) throw new IllegalStateException("Request in context!"); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/SecureRequestCustomizer.java b/jetty-server/src/main/java/org/eclipse/jetty/server/SecureRequestCustomizer.java index ab0457f05aa..27f9c0c9360 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/SecureRequestCustomizer.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/SecureRequestCustomizer.java @@ -72,7 +72,13 @@ public class SecureRequestCustomizer implements HttpConfiguration.Customizer SslConnection sslConnection = ssl_endp.getSslConnection(); SSLEngine sslEngine=sslConnection.getSSLEngine(); customize(sslEngine,request); + + if (request.getHttpURI().getScheme()==null) + request.setScheme(HttpScheme.HTTPS.asString()); } + + if (HttpScheme.HTTPS.is(request.getScheme())) + request.setSecure(true); } /** @@ -99,10 +105,6 @@ public class SecureRequestCustomizer implements HttpConfiguration.Customizer */ public void customize(SSLEngine sslEngine, Request request) { - request.setSecure(true); - if (request.getHttpURI().getScheme()==null) - request.getHttpURI().setScheme(HttpScheme.HTTPS.asString()); - SSLSession sslSession = sslEngine.getSession(); if (_sniHostCheck)