Merged remote branch 'jetty-9.2.x' into 'master'.

This commit is contained in:
Simone Bordet 2015-05-28 15:39:42 +02:00
commit 061a8e253e
3 changed files with 43 additions and 3 deletions

View File

@ -528,7 +528,8 @@ public class HttpClient extends ContainerLifeCycle
if (!HttpScheme.HTTP.is(scheme) && !HttpScheme.HTTPS.is(scheme))
throw new IllegalArgumentException("Invalid protocol " + scheme);
HttpDestination destination = destinationFor(scheme, request.getHost(), request.getPort());
String host = request.getHost().toLowerCase(Locale.ENGLISH);
HttpDestination destination = destinationFor(scheme, host, request.getPort());
destination.send(request, listeners);
}

View File

@ -161,9 +161,9 @@ public abstract class HttpDestination implements Destination, Closeable, Dumpabl
protected void send(HttpRequest request, List<Response.ResponseListener> listeners)
{
if (!getScheme().equals(request.getScheme()))
if (!getScheme().equalsIgnoreCase(request.getScheme()))
throw new IllegalArgumentException("Invalid request scheme " + request.getScheme() + " for destination " + this);
if (!getHost().equals(request.getHost()))
if (!getHost().equalsIgnoreCase(request.getHost()))
throw new IllegalArgumentException("Invalid request host " + request.getHost() + " for destination " + this);
int port = request.getPort();
if (port >= 0 && getPort() != port)

View File

@ -432,4 +432,43 @@ public class HttpClientURITest extends AbstractHttpClientServerTest
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
}
@Test
public void testSchemeIsCaseInsensitive() throws Exception
{
start(new AbstractHandler()
{
@Override
public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
baseRequest.setHandled(true);
}
});
ContentResponse response = client.newRequest("localhost", connector.getLocalPort())
.scheme(scheme.toUpperCase())
.timeout(5, TimeUnit.SECONDS)
.send();
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
}
@Test
public void testHostIsCaseInsensitive() throws Exception
{
start(new AbstractHandler()
{
@Override
public void handle(String target, org.eclipse.jetty.server.Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
baseRequest.setHandled(true);
}
});
ContentResponse response = client.newRequest("LOCALHOST", connector.getLocalPort())
.scheme(scheme)
.timeout(5, TimeUnit.SECONDS)
.send();
Assert.assertEquals(HttpStatus.OK_200, response.getStatus());
}
}