Added test that verifies that the host header is correctly

overwritten by a user-provided value.
This commit is contained in:
Simone Bordet 2013-12-10 16:59:54 +01:00
parent 7a235e6e69
commit 6f87a9b995
1 changed files with 22 additions and 0 deletions

View File

@ -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());
}
}