From 36de309e9f7e33e53f7781393f5e7cc49938a6b9 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 28 Oct 2015 17:33:05 +1100 Subject: [PATCH] 480162 - Continuations behavior differences due to HttpURI behavior Cleaned up handling of original URI --- .../src/main/java/org/eclipse/jetty/http/HttpURI.java | 1 + .../main/java/org/eclipse/jetty/http/MetaData.java | 1 - .../eclipse/jetty/server/AbstractNCSARequestLog.java | 2 +- .../main/java/org/eclipse/jetty/server/Request.java | 11 +++++++++++ .../eclipse/jetty/server/SecureRequestCustomizer.java | 10 ++++++---- 5 files changed, 19 insertions(+), 6 deletions(-) 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)