summaryrefslogtreecommitdiffstats
path: root/jdisc_core
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2020-12-21 12:48:51 +0100
committerJon Marius Venstad <venstad@gmail.com>2020-12-21 12:48:51 +0100
commitb962664eb83a80d7a3f1e8b0284796d421a253c8 (patch)
tree6cefb288fe1d17d55cd74fd59626564361518ae3 /jdisc_core
parent4c1e1dff938c79360c8c9cf38c2dd9fd14845ee7 (diff)
Require port to be present in given URI when specified in binding
Diffstat (limited to 'jdisc_core')
-rw-r--r--jdisc_core/src/main/java/com/yahoo/jdisc/application/UriPattern.java16
-rw-r--r--jdisc_core/src/test/java/com/yahoo/jdisc/application/UriPatternTestCase.java9
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 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<UriPattern> {
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<UriPattern> {
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;
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 4b5ff271dfa..4b196265e80 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
@@ -289,15 +289,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);