mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-01 19:39:21 +00:00
Fixes #1069 - Host header should be sent with HTTP/1.0.
This commit is contained in:
parent
fba901d156
commit
d18b900b75
@ -113,7 +113,7 @@ public abstract class HttpConnection implements Connection
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we are HTTP 1.1, add the Host header
|
// If we are HTTP 1.1, add the Host header
|
||||||
if (version.getVersion() == 11)
|
if (version.getVersion() <= 11)
|
||||||
{
|
{
|
||||||
if (!headers.containsKey(HttpHeader.HOST.asString()))
|
if (!headers.containsKey(HttpHeader.HOST.asString()))
|
||||||
headers.put(getHttpDestination().getHostField());
|
headers.put(getHttpDestination().getHostField());
|
||||||
|
@ -1562,8 +1562,7 @@ public class HttpClientTest extends AbstractHttpClientServerTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCopyRequest()
|
public void testCopyRequest() throws Exception
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
startClient();
|
startClient();
|
||||||
|
|
||||||
@ -1610,6 +1609,28 @@ public class HttpClientTest extends AbstractHttpClientServerTest
|
|||||||
.header("X-Custom-Header-2", "value"));
|
.header("X-Custom-Header-2", "value"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testHostWithHTTP10() 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);
|
||||||
|
Assert.assertThat(request.getHeader("Host"), Matchers.notNullValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ContentResponse response = client.newRequest("localhost", connector.getLocalPort())
|
||||||
|
.scheme(scheme)
|
||||||
|
.version(HttpVersion.HTTP_1_0)
|
||||||
|
.timeout(5, TimeUnit.SECONDS)
|
||||||
|
.send();
|
||||||
|
|
||||||
|
Assert.assertEquals(200, response.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
private void assertCopyRequest(Request original)
|
private void assertCopyRequest(Request original)
|
||||||
{
|
{
|
||||||
Request copy = client.copyRequest((HttpRequest) original, original.getURI());
|
Request copy = client.copyRequest((HttpRequest) original, original.getURI());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user