diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2020-12-22 11:14:04 +0100 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2020-12-22 11:14:04 +0100 |
commit | a2c96dc78bf1e88b9378affea73d112945a28bcf (patch) | |
tree | 6228f8e24675aaa3b036442429460b756a426c37 /jdisc_core | |
parent | 5d3423debd9db43dc7c34eeb034b3540da1a85e7 (diff) |
Revert "Revert require port from URI when specified in binding"
This reverts commit ea50af2f89c8bc5ba8b132b971c082a8cce4ad54.
Diffstat (limited to 'jdisc_core')
-rw-r--r-- | jdisc_core/src/main/java/com/yahoo/jdisc/application/UriPattern.java | 16 | ||||
-rw-r--r-- | jdisc_core/src/test/java/com/yahoo/jdisc/application/UriPatternTestCase.java | 9 |
2 files changed, 1 insertions, 24 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/UriPattern.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/UriPattern.java index 016a2fd796a..53d276b3fb6 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/UriPattern.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/UriPattern.java @@ -95,7 +95,7 @@ public class UriPattern implements Comparable<UriPattern> { */ public Match match(URI uri) { // Performance optimization: match in order of increasing cost and decreasing discriminating power. - if (port > 0 && port != portOrSchemeDefault(uri)) + if (port > 0 && port != uri.getPort()) return null; String uriPath = nonNullOrBlank(uri.getRawPath()); @@ -172,20 +172,6 @@ public class UriPattern implements Comparable<UriPattern> { return Integer.parseInt(str); } - private static int portOrSchemeDefault(URI uri) { - return uri.getPort() != -1 ? uri.getPort() - : schemeDefaultPort(uri.getScheme()); - } - - private static int schemeDefaultPort(String scheme) { - if (scheme == null) return -1; - switch (scheme) { - case "http": return 80; - case "https": return 443; - default: return -1; - } - } - private static String normalizeScheme(String scheme) { if (scheme.equals("https")) return "http"; // handle 'https' in bindings and uris as 'http' return scheme; diff --git a/jdisc_core/src/test/java/com/yahoo/jdisc/application/UriPatternTestCase.java b/jdisc_core/src/test/java/com/yahoo/jdisc/application/UriPatternTestCase.java index c7d0b9ff6d2..0ea82508f06 100644 --- a/jdisc_core/src/test/java/com/yahoo/jdisc/application/UriPatternTestCase.java +++ b/jdisc_core/src/test/java/com/yahoo/jdisc/application/UriPatternTestCase.java @@ -263,15 +263,6 @@ public class UriPatternTestCase { } @Test - public void requireThatUrisWithImplicitPortFromSchemeMatchesBindingWithExplicitPort() { - UriPattern httpPattern = new UriPattern("http://host:80/path"); - assertMatch(httpPattern, "http://host/path", NO_GROUPS); - - UriPattern httpsPattern = new UriPattern("https://host:443/path"); - assertMatch(httpsPattern, "https://host/path", NO_GROUPS); - } - - @Test public void requireThatHttpsSchemeIsHandledAsHttp() { UriPattern httpPattern = new UriPattern("http://host:80/path"); assertMatch(httpPattern, "https://host:80/path", NO_GROUPS); |