Merged branch 'jetty-9.3.x' into 'jetty-9.4.x'.

This commit is contained in:
Simone Bordet 2016-11-04 09:54:36 +01:00
commit 605aadba59
2 changed files with 24 additions and 3 deletions

View File

@ -112,7 +112,7 @@ public abstract class HttpConnection implements Connection
}
// If we are HTTP 1.1, add the Host header
if (version.getVersion() == 11)
if (version.getVersion() <= 11)
{
if (!headers.containsKey(HttpHeader.HOST.asString()))
headers.put(getHttpDestination().getHostField());

View File

@ -1582,8 +1582,7 @@ public class HttpClientTest extends AbstractHttpClientServerTest
}
@Test
public void testCopyRequest()
throws Exception
public void testCopyRequest() throws Exception
{
startClient();
@ -1630,6 +1629,28 @@ public class HttpClientTest extends AbstractHttpClientServerTest
.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)
{
Request copy = client.copyRequest((HttpRequest) original, original.getURI());