From 0e3bb5a7977b4d756125279ab8aa74720acda302 Mon Sep 17 00:00:00 2001 From: petromykhailysyn Date: Fri, 22 Jan 2016 10:42:36 +0200 Subject: [PATCH 1/3] If servletContextPath is not root (application is deployed not to the root) we should take it into consideration while determinating server base. --- .../fhir/rest/server/IncomingRequestAddressStrategy.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java index 1edad7968d5..b2f72cc0e40 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java @@ -73,7 +73,12 @@ public class IncomingRequestAddressStrategy implements IServerAddressStrategy { } String fhirServerBase; - int length = contextIndex + servletPath.length(); + int length; + if (servletContextPath.length() == 0 || servletContextPath.equals("/")) { + length = contextIndex + servletPath.length(); + } else { + length = contextIndex + servletPath.length() + servletContextPath.length(); + } if (length > requestUrlLength) { length = requestUrlLength; } From 83823aad356df86771677fdd5d9a05d163bb709e Mon Sep 17 00:00:00 2001 From: petromykhailysyn Date: Tue, 26 Jan 2016 16:29:16 +0200 Subject: [PATCH 2/3] ServletContextPath can start with servletPath, now it's taking into consideration while determinate contextIndex. --- .../rest/server/IncomingRequestAddressStrategy.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java index b2f72cc0e40..f65f009019d 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java @@ -69,16 +69,12 @@ public class IncomingRequestAddressStrategy implements IServerAddressStrategy { contextIndex = requestUrl.indexOf(requestPath, startOfPath); } } else { - contextIndex = requestUrl.indexOf(servletPath, startOfPath); + //servletContextPath can start with servletPath + contextIndex = requestUrl.indexOf(servletPath + "/", startOfPath); } String fhirServerBase; - int length; - if (servletContextPath.length() == 0 || servletContextPath.equals("/")) { - length = contextIndex + servletPath.length(); - } else { - length = contextIndex + servletPath.length() + servletContextPath.length(); - } + int length = contextIndex + servletPath.length(); if (length > requestUrlLength) { length = requestUrlLength; } From a7313023f7d33df7cb64693f2a509678df38eec4 Mon Sep 17 00:00:00 2001 From: petromykhailysyn Date: Tue, 26 Jan 2016 17:02:24 +0200 Subject: [PATCH 3/3] Revert "If servletContextPath is not root (application is deployed not to the root) we should take it into consideration while determinating server base." This reverts commit 0e3bb5a7977b4d756125279ab8aa74720acda302. --- .../uhn/fhir/rest/server/IncomingRequestAddressStrategy.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java index f65f009019d..c018a2e29bb 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/IncomingRequestAddressStrategy.java @@ -71,6 +71,9 @@ public class IncomingRequestAddressStrategy implements IServerAddressStrategy { } else { //servletContextPath can start with servletPath contextIndex = requestUrl.indexOf(servletPath + "/", startOfPath); + if (contextIndex == -1) { + contextIndex = requestUrl.indexOf(servletPath, startOfPath); + } } String fhirServerBase;