Package org.apache.catalina.util
Class RequestUtil
- java.lang.Object
-
- org.apache.catalina.util.RequestUtil
-
public final class RequestUtil extends java.lang.ObjectGeneral purpose request parsing and encoding utility methods.
-
-
Constructor Summary
Constructors Constructor Description RequestUtil()Default constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetMergedHeaderValue(HttpServletRequest request, java.lang.String headerName)Behaves the same way asHttpServletRequest.getHeader(String)but with the addition that, if multiple headers of the specified name are present, the values are concatenated (with commas) before returning a single combined value.static java.lang.StringBuffergetRequestURL(HttpServletRequest request)Build an appropriate return value forHttpServletRequest.getRequestURL()based on the provided request object.static booleanisSameWebApplication(HttpServletRequest request, java.net.URL url)Tests whether the provided URL is for a resource contained within the same web application as the request.static java.lang.StringstripPathParams(java.lang.String input, Request request)Strip parameters for given path.
-
-
-
Method Detail
-
getRequestURL
public static java.lang.StringBuffer getRequestURL(HttpServletRequest request)
Build an appropriate return value forHttpServletRequest.getRequestURL()based on the provided request object. Note that this will also work for instances ofHttpServletRequestWrapper.- Parameters:
request- The request object for which the URL should be built- Returns:
- The request URL for the given request object
-
stripPathParams
public static java.lang.String stripPathParams(java.lang.String input, Request request)Strip parameters for given path.- Parameters:
input- the input pathrequest- the request to add the parameters to- Returns:
- the cleaned path
-
isSameWebApplication
public static boolean isSameWebApplication(HttpServletRequest request, java.net.URL url)
Tests whether the provided URL is for a resource contained within the same web application as the request.- Parameters:
request- The request to testurl- The URL to test- Returns:
trueif the provided URL is for a resource contained within the same web application as the request, otherwisefalse
-
getMergedHeaderValue
public static java.lang.String getMergedHeaderValue(HttpServletRequest request, java.lang.String headerName)
Behaves the same way asHttpServletRequest.getHeader(String)but with the addition that, if multiple headers of the specified name are present, the values are concatenated (with commas) before returning a single combined value.- Parameters:
request- The request from which the header value(s) should be retrievedheaderName- The name of the HTTP header for which the merged value should be obtained- Returns:
- The merged value for the given HTTP header.
-
-