Added test that verifies that the host header is correctly
overwritten by a user-provided value.
This commit is contained in:
parent
7a235e6e69
commit
6f87a9b995
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue