Merge remote-tracking branch 'origin/jetty-9.3.x'
This commit is contained in:
commit
7415163f59
|
@ -97,6 +97,8 @@ public class GlobalWebappConfigBinding implements AppLifeCycle.Binding
|
|||
Resource resource = Resource.newResource(app.getOriginId());
|
||||
File file = resource.getFile();
|
||||
jettyXmlConfig.getIdMap().put("Server",app.getDeploymentManager().getServer());
|
||||
jettyXmlConfig.getProperties().put("jetty.home",System.getProperty("jetty.home","."));
|
||||
jettyXmlConfig.getProperties().put("jetty.base",System.getProperty("jetty.base","."));
|
||||
jettyXmlConfig.getProperties().put("jetty.webapp",file.getCanonicalPath());
|
||||
jettyXmlConfig.getProperties().put("jetty.webapps",file.getParentFile().getCanonicalPath());
|
||||
|
||||
|
|
|
@ -167,4 +167,24 @@ public class HttpURITest
|
|||
assertEquals("p2",uri.getParam());
|
||||
assertEquals("other=123456",uri.getQuery());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSchemeAndOrAuthority() throws Exception
|
||||
{
|
||||
HttpURI uri = new HttpURI("/path/info");
|
||||
assertEquals("/path/info",uri.toString());
|
||||
|
||||
uri.setAuthority("host",0);
|
||||
assertEquals("//host/path/info",uri.toString());
|
||||
|
||||
uri.setAuthority("host",8888);
|
||||
assertEquals("//host:8888/path/info",uri.toString());
|
||||
|
||||
uri.setScheme("http");
|
||||
assertEquals("http://host:8888/path/info",uri.toString());
|
||||
|
||||
uri.setAuthority(null,0);
|
||||
assertEquals("http:/path/info",uri.toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.eclipse.jetty.http.HttpHeader;
|
|||
import org.eclipse.jetty.http.HttpHeaderValue;
|
||||
import org.eclipse.jetty.http.HttpMethod;
|
||||
import org.eclipse.jetty.http.HttpParser;
|
||||
import org.eclipse.jetty.http.HttpScheme;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.http.HttpURI;
|
||||
import org.eclipse.jetty.http.HttpVersion;
|
||||
|
@ -130,8 +129,6 @@ class HttpChannelOverHttp extends HttpChannel implements HttpParser.RequestHandl
|
|||
if (!_metadata.getURI().isAbsolute() && field instanceof HostPortHttpField)
|
||||
{
|
||||
HostPortHttpField hp = (HostPortHttpField)field;
|
||||
// Set scheme default value as 'http' (can be overridden later in SecureRequestCustomizer)
|
||||
_metadata.getURI().setScheme(HttpScheme.HTTP.asString());
|
||||
_metadata.getURI().setAuthority(hp.getHost(),hp.getPort());
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1353,7 +1353,7 @@ public class Request implements HttpServletRequest
|
|||
@Override
|
||||
public String getScheme()
|
||||
{
|
||||
String scheme=_metadata.getURI().getScheme();
|
||||
String scheme=_metadata==null?null:_metadata.getURI().getScheme();
|
||||
return scheme==null?HttpScheme.HTTP.asString():scheme;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,8 +68,11 @@ public class SecureRequestCustomizer implements HttpConfiguration.Customizer
|
|||
{
|
||||
if (request.getHttpChannel().getEndPoint() instanceof DecryptedEndPoint)
|
||||
{
|
||||
request.setScheme(HttpScheme.HTTPS.asString());
|
||||
request.setSecure(true);
|
||||
|
||||
if (request.getHttpURI().getScheme()==null)
|
||||
request.setScheme(HttpScheme.HTTPS.asString());
|
||||
|
||||
SslConnection.DecryptedEndPoint ssl_endp = (DecryptedEndPoint)request.getHttpChannel().getEndPoint();
|
||||
SslConnection sslConnection = ssl_endp.getSslConnection();
|
||||
SSLEngine sslEngine=sslConnection.getSSLEngine();
|
||||
|
|
|
@ -533,6 +533,7 @@ public class ResponseTest
|
|||
Response response = newResponse();
|
||||
Request request = response.getHttpChannel().getRequest();
|
||||
|
||||
request.setScheme("http");
|
||||
request.setAuthority(host,port);
|
||||
request.setURIPathQuery("/path/info;param;jsessionid=12345?query=0&more=1#target");
|
||||
request.setContextPath("/path");
|
||||
|
|
|
@ -158,7 +158,7 @@ public class DebugHandlerTest
|
|||
req.getString("/foo/bar?a=b");
|
||||
|
||||
String log = capturedLog.toString(StandardCharsets.UTF_8.name());
|
||||
String expectedThreadName = String.format("http://%s:%s/foo/bar?a=b",serverURI.getHost(),serverURI.getPort());
|
||||
String expectedThreadName = String.format("//%s:%s/foo/bar?a=b",serverURI.getHost(),serverURI.getPort());
|
||||
assertThat("ThreadName", log, containsString(expectedThreadName));
|
||||
// Look for bad/mangled/duplicated schemes
|
||||
assertThat("ThreadName", log, not(containsString("http:"+expectedThreadName)));
|
||||
|
|
|
@ -66,6 +66,7 @@ public class RequestLogTest
|
|||
_server.stop();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNotHandled() throws Exception
|
||||
{
|
||||
|
@ -73,6 +74,30 @@ public class RequestLogTest
|
|||
String log = _log.exchange(null,5,TimeUnit.SECONDS);
|
||||
assertThat(log,containsString("GET /foo HTTP/1.0\" 404 "));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRequestLine() throws Exception
|
||||
{
|
||||
_connector.getResponses("GET /foo?data=1 HTTP/1.0\nhost: host:80\n\n");
|
||||
String log = _log.exchange(null,5,TimeUnit.SECONDS);
|
||||
// TODO should be without host (https://bugs.eclipse.org/bugs/show_bug.cgi?id=480276)
|
||||
// assertThat(log,containsString("GET /foo?data=1 HTTP/1.0\" 200 "));
|
||||
assertThat(log,containsString("GET //host:80/foo?data=1 HTTP/1.0\" 200 "));
|
||||
|
||||
_connector.getResponses("GET //host/foo?data=1 HTTP/1.0\n\n");
|
||||
log = _log.exchange(null,5,TimeUnit.SECONDS);
|
||||
assertThat(log,containsString("GET //host/foo?data=1 HTTP/1.0\" 200 "));
|
||||
|
||||
_connector.getResponses("GET //absolute:80/foo?data=1 HTTP/1.0\nhost: host:80\n\n");
|
||||
log = _log.exchange(null,5,TimeUnit.SECONDS);
|
||||
// TODO should it be with absolute? (https://bugs.eclipse.org/bugs/show_bug.cgi?id=480276)
|
||||
// assertThat(log,containsString("GET //absolute:80/foo?data=1 HTTP/1.0\" 200 "));
|
||||
assertThat(log,containsString("GET //host:80/foo?data=1 HTTP/1.0\" 200 "));
|
||||
|
||||
_connector.getResponses("GET http://host:80/foo?data=1 HTTP/1.0\n\n");
|
||||
log = _log.exchange(null,5,TimeUnit.SECONDS);
|
||||
assertThat(log,containsString("GET http://host:80/foo?data=1 HTTP/1.0\" 200 "));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSmallData() throws Exception
|
||||
|
|
|
@ -35,7 +35,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.Servlet;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletRegistration.Dynamic;
|
||||
import javax.servlet.ServletSecurityElement;
|
||||
|
@ -60,7 +59,6 @@ import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
|
|||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
||||
import org.eclipse.jetty.servlet.ServletHandler;
|
||||
import org.eclipse.jetty.util.AttributesMap;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.Loader;
|
||||
import org.eclipse.jetty.util.MultiException;
|
||||
import org.eclipse.jetty.util.URIUtil;
|
||||
|
|
Loading…
Reference in New Issue