From b962664eb83a80d7a3f1e8b0284796d421a253c8 Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Mon, 21 Dec 2020 12:48:51 +0100 Subject: Require port to be present in given URI when specified in binding --- .../java/com/yahoo/jdisc/application/UriPattern.java | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'jdisc_core/src/main/java/com/yahoo/jdisc/application') 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 b6aebec4d8d..84a7e8066f9 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 @@ -100,7 +100,7 @@ public class UriPattern implements Comparable { if (pathMatch == null) { return null; } - if (port > 0 && port != portOrSchemeDefault(uri)) { + if (port > 0 && port != uri.getPort()) { return null; } // Match scheme before host because it has a higher chance of differing (e.g. http versus https) @@ -171,20 +171,6 @@ public class UriPattern implements Comparable { return Integer.parseInt(str); } - private static int portOrSchemeDefault(URI uri) { - int rawPort = uri.getPort(); - return rawPort != -1 ? rawPort : 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; -- cgit v1.2.3