diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java index be4a2b3be73..14134063a00 100644 --- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java +++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientTest.java @@ -1051,4 +1051,26 @@ public class HttpClientTest extends AbstractHttpClientServerTest Assert.assertArrayEquals(content, listener.getContent()); Assert.assertArrayEquals(content, response.getContent()); } + + @Test + public void testCustomHostHeader() throws Exception + { + final String host = "localhost"; + 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); + Assert.assertEquals(host, request.getServerName()); + } + }); + + ContentResponse response = client.newRequest("http://127.0.0.1:" + connector.getLocalPort() + "/path") + .scheme(scheme) + .header(HttpHeader.HOST, host) + .send(); + + Assert.assertEquals(200, response.getStatus()); + } }