From 0e3bb5a7977b4d756125279ab8aa74720acda302 Mon Sep 17 00:00:00 2001 From: petromykhailysyn Date: Fri, 22 Jan 2016 10:42:36 +0200 Subject: [PATCH] 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; }