Skip to content

Commit

Permalink
Fix #6860 IPv6 Format (#6861)
Browse files Browse the repository at this point in the history
Fix #6860 IPv6 format by adding an extensible HttpChannel method

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Co-authored-by: Lachlan Roberts <lachlan@webtide.com>
Signed-off-by: Greg Wilkins <gregw@webtide.com>
# Conflicts:
#	jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java
#	jetty-server/src/main/java/org/eclipse/jetty/server/Request.java
#	jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java
#	jetty-server/src/test/java/org/eclipse/jetty/server/RequestTest.java
  • Loading branch information
gregw committed Sep 23, 2021
1 parent 1404bc5 commit 72f3479
Showing 1 changed file with 10 additions and 8 deletions.
Expand Up @@ -74,7 +74,6 @@
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jetty.http.tools.matchers.HttpFieldsMatchers.containsHeader;
import static org.eclipse.jetty.http.tools.matchers.HttpFieldsMatchers.containsHeaderValue;
import static org.eclipse.jetty.http.HttpFieldsMatchers.headerValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsString;
Expand Down Expand Up @@ -882,25 +881,25 @@ public void testWelcomeRedirect() throws Exception
rawResponse = connector.getResponse("GET /context/dir/ HTTP/1.0\r\n\r\n");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
assertThat(response, headerValue("Location", "http://0.0.0.0/context/dir/index.html"));
assertThat(response, containsHeaderValue("Location", "http://0.0.0.0/context/dir/index.html"));

createFile(inde, "<h1>Hello Inde</h1>");
rawResponse = connector.getResponse("GET /context/dir HTTP/1.0\r\n\r\n");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
assertThat(response, headerValue("Location", "http://0.0.0.0/context/dir/"));
assertThat(response, containsHeaderValue("Location", "http://0.0.0.0/context/dir/"));

rawResponse = connector.getResponse("GET /context/dir/ HTTP/1.0\r\n\r\n");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
assertThat(response, headerValue("Location", "http://0.0.0.0/context/dir/index.html"));
assertThat(response, containsHeaderValue("Location", "http://0.0.0.0/context/dir/index.html"));

if (deleteFile(index))
{
rawResponse = connector.getResponse("GET /context/dir/ HTTP/1.0\r\n\r\n");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
assertThat(response, headerValue("Location", "http://0.0.0.0/context/dir/index.htm"));
assertThat(response, containsHeaderValue("Location", "http://0.0.0.0/context/dir/index.htm"));

if (deleteFile(inde))
{
Expand Down Expand Up @@ -938,17 +937,20 @@ public void testRelativeRedirect() throws Exception
rawResponse = connector.getResponse("GET /context/dir HTTP/1.0\r\n\r\n");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
assertThat(response, headerValue("Location", "/context/dir/"));
assertThat(response, containsHeaderValue("Location", "/context/dir/"));
assertThat(response, not(containsHeaderValue("Location", "http://")));

rawResponse = connector.getResponse("GET /context/dir/ HTTP/1.0\r\n\r\n");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
assertThat(response, headerValue("Location", "/context/dir/index.html"));
assertThat(response, containsHeaderValue("Location", "/context/dir/index.html"));
assertThat(response, not(containsHeaderValue("Location", "http://")));

rawResponse = connector.getResponse("GET /context/dir/index.html/ HTTP/1.0\r\n\r\n");
response = HttpTester.parseResponse(rawResponse);
assertThat(response.toString(), response.getStatus(), is(HttpStatus.MOVED_TEMPORARILY_302));
assertThat(response, headerValue("Location", "/context/dir/index.html"));
assertThat(response, containsHeaderValue("Location", "/context/dir/index.html"));
assertThat(response, not(containsHeaderValue("Location", "http://")));
}

/**
Expand Down

0 comments on commit 72f3479

Please sign in to comment.