Skip to content

Commit

Permalink
Remove context path override prefix when handling a request, so that …
Browse files Browse the repository at this point in the history
…the real path to the resource is extracted properly
  • Loading branch information
albanf committed Jan 3, 2019
1 parent 5381f6a commit ed29c29
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,8 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro

String requestedPath = "".equals(jawrConfig.getServletMapping()) ? request.getServletPath()
: request.getPathInfo();
// Remove context override prefix from the requested path
requestedPath = removePathOverridePrefix(request, requestedPath);
processRequest(requestedPath, request, response);

} catch (Exception e) {
Expand All @@ -662,6 +664,26 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
}
}

/**
* Remove the context override prefix from the requestedPath
*
* @param request the request
* @param requestedPath the requested path
* @return the requested path without the context override prefix
*/
public String removePathOverridePrefix(HttpServletRequest request, String requestedPath) {
String prefix;
if (request.isSecure()) {
prefix = jawrConfig.getContextPathSslOverride();
} else {
prefix = jawrConfig.getContextPathOverride();
}
if (prefix != null) {
return requestedPath.substring(prefix.length());
}
return requestedPath;
}

/**
* Handles a resource request.
* <ul>
Expand Down

0 comments on commit ed29c29

Please sign in to comment.