Skip to content

Commit

Permalink
Exception in Jersey Jetty handler's Host header parsing bubbles up to…
Browse files Browse the repository at this point in the history
… the top eclipse-ee4j#5189

Signed-off-by: Jorge Bescos Gascon <jorge.bescos.gascon@oracle.com>
  • Loading branch information
jbescos committed Nov 11, 2022
1 parent b46e89f commit 1c85a26
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,9 @@ public String getAuthenticationScheme() {
}


private URI getBaseUri(final Request request) {
try {
return new URI(request.getScheme(), null, request.getServerName(),
request.getServerPort(), getBasePath(request), null, null);
} catch (final URISyntaxException ex) {
throw new IllegalArgumentException(ex);
}
private URI getBaseUri(final Request request) throws URISyntaxException {
return new URI(request.getScheme(), null, request.getServerName(),
request.getServerPort(), getBasePath(request), null, null);
}

private String getBasePath(final Request request) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -65,6 +65,19 @@ public void test400StatusCodeForIllegalSymbolsInURI() throws IOException {
assertEquals(400, response.getStatusLine().getStatusCode());
}

@Test
public void test400StatusCodeForIllegalHeaderValue() throws IOException {
startServer(ExceptionResource.class);
URI testUri = getUri().build();
BasicHttpRequest request = new BasicHttpRequest("GET", testUri.toString() + "/400");
request.addHeader("X-Forwarded-Host", "_foo.com");
CloseableHttpClient client = HttpClientBuilder.create().build();

CloseableHttpResponse response = client.execute(new HttpHost(testUri.getHost(), testUri.getPort()), request);

assertEquals(400, response.getStatusLine().getStatusCode());
}

@Test
public void test400StatusCode() throws IOException {
startServer(ExceptionResource.class);
Expand Down

0 comments on commit 1c85a26

Please sign in to comment.