Skip to content

Commit

Permalink
Issue #7269 - Updates per review
Browse files Browse the repository at this point in the history
Signed-off-by: Joakim Erdfelt <[email protected]>
  • Loading branch information
joakime committed Dec 15, 2021
1 parent 19f4e74 commit e55d6dc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ private boolean updateForwardedHandle(MethodHandles.Lookup lookup, String header
private static class MutableHostPort
{
public static final int UNSET = HostPort.NO_PORT;
public static final int IMPLIED = -2;
public static final int IMPLIED = HostPort.NO_PORT - 1;

String _host;
Source _hostSource = Source.UNSET;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.server.handler.ErrorHandler;
import org.eclipse.jetty.toolchain.test.Net;
import org.eclipse.jetty.util.HostPort;
import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.util.log.StacklessLogging;
import org.hamcrest.Matchers;
Expand Down Expand Up @@ -180,7 +181,7 @@ public void testLocalV2(RequestProcessor p) throws Exception

assertThat(response, Matchers.containsString("HTTP/1.1 200"));
assertThat(response, Matchers.containsString("pathInfo=/path"));
assertThat(response, Matchers.containsString("local=0.0.0.0:-1")); // LocalConnector has no local host or local port
assertThat(response, Matchers.containsString("local=0.0.0.0:" + HostPort.NO_PORT)); // LocalConnector has no local name or local port
assertThat(response, Matchers.containsString("remote=0.0.0.0:0"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.HostPort;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
Expand Down Expand Up @@ -1002,7 +1003,7 @@ public boolean check(HttpServletRequest request, HttpServletResponse response)
assertEquals("[::1]", results.get(i++));
assertEquals("8888", results.get(i++));
assertEquals("0.0.0.0", results.get(i++));
assertEquals("-1", results.get(i)); // local connector has no local port
assertEquals(String.valueOf(HostPort.NO_PORT), results.get(i)); // local connector has no local port

_normalizeAddress = false;
results.clear();
Expand All @@ -1019,7 +1020,7 @@ public boolean check(HttpServletRequest request, HttpServletResponse response)
assertEquals("[::1]", results.get(i++));
assertEquals("8888", results.get(i++));
assertEquals("0.0.0.0", results.get(i++));
assertEquals("-1", results.get(i)); // local connector has no local port
assertEquals(String.valueOf(HostPort.NO_PORT), results.get(i)); // local connector has no local port
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ private static Stream<Arguments> validAuthorityProvider()
Arguments.of(" host : 777", "host", 777),
Arguments.of(" host :777 ", "host", 777),
Arguments.of(" host : 777 ", "host", 777),
Arguments.of("host: ", "host", null),
// scheme based normalization https://datatracker.ietf.org/doc/html/rfc3986#section-6.2.3
Arguments.of("host:", "host", null),
Arguments.of("host: ", "host", null),
Arguments.of("127.0.0.1:", "127.0.0.1", null),
// Localhost tests
Arguments.of("localhost:80", "localhost", 80),
Expand Down

0 comments on commit e55d6dc

Please sign in to comment.