public class HstRequestUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
createURLWithExplicitSchemeForRequest(String scheme,
Mount mount,
javax.servlet.http.HttpServletRequest request)
Creates the same fully qualified URL as the client used to make the request, only force the scheme of the URL to be equal
to the
scheme parameter instead of the scheme of the request . |
static String |
escapeXml(String str)
Replaces in String str the characters &,>,<,",'
with their corresponding character entity codes.
|
static String |
getFarthestRemoteAddr(javax.servlet.http.HttpServletRequest request)
Returns the remote client address.
|
static String |
getFarthestRequestHost(javax.servlet.http.HttpServletRequest request)
Returns the original host information requested by the client.
|
static String |
getFarthestRequestHost(javax.servlet.http.HttpServletRequest request,
boolean checkRenderHost)
Returns the original host information requested by the client and do check optional
injected render host information only when
checkRenderHost is true |
static String |
getFarthestRequestScheme(javax.servlet.http.HttpServletRequest request) |
static String |
getFullyQualifiedHstURL(HstRequestContext requestContext,
HstURL hstUrl,
boolean escapeXml)
Returns a fully qualified String url for the
HstURL hstUrl . |
static HstRequest |
getHstRequest(javax.servlet.http.HttpServletRequest servletRequest)
Returns
HstRequest object found in the servletRequest. |
static HstRequestContext |
getHstRequestContext(javax.servlet.http.HttpServletRequest servletRequest)
Returns
HstRequestContext object found in the servletRequest. |
static HstResponse |
getHstResponse(javax.servlet.http.HttpServletRequest servletRequest,
javax.servlet.http.HttpServletResponse servletResponse)
Returns
HstResponse object found in the servletRequest or servletResponse. |
static String |
getPathInfo(ResolvedMount mount,
javax.servlet.http.HttpServletRequest request)
Returns any extra path information associated with the URL the client sent when it made this request.
|
static String |
getPathInfo(ResolvedMount mount,
javax.servlet.http.HttpServletRequest request,
String characterEncoding)
Returns any extra path information associated with the URL the client sent when it made this request.
|
static String[] |
getRemoteAddrs(javax.servlet.http.HttpServletRequest request)
Returns the remote host addresses related to this request.
|
static String |
getRenderingHost(javax.servlet.http.HttpServletRequest request)
Returns the rendering host of the current request, i.e.
|
static String[] |
getRequestHosts(javax.servlet.http.HttpServletRequest request)
Returns the original host informations requested by the client or the proxies
in the Host HTTP request headers.
|
static String[] |
getRequestHosts(javax.servlet.http.HttpServletRequest request,
boolean checkRenderHost)
Returns HTTP/1.1 compatible 'Host' header value.
|
static String |
getRequestPath(javax.servlet.http.HttpServletRequest request) |
static String |
getRequestPath(javax.servlet.http.HttpServletRequest request,
String characterEncoding) |
static String |
getRequestServerName(javax.servlet.http.HttpServletRequest request)
Returns the original host's server name requested by the client.
|
static int |
getRequestServerPort(javax.servlet.http.HttpServletRequest request)
Returns the original host' port number requested by the client.
|
static String |
getRequestURI(javax.servlet.http.HttpServletRequest request,
boolean excludeMatrixParameters) |
static Map<String,String[]> |
parseQueryString(javax.servlet.http.HttpServletRequest request) |
static String |
removeAllMatrixParams(String uri) |
public static HstRequest getHstRequest(javax.servlet.http.HttpServletRequest servletRequest)
HstRequest
object found in the servletRequest.servletRequest
- public static HstResponse getHstResponse(javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse)
HstResponse
object found in the servletRequest or servletResponse.servletRequest
- servletResponse
- public static HstRequestContext getHstRequestContext(javax.servlet.http.HttpServletRequest servletRequest)
HstRequestContext
object found in the servletRequest.servletRequest
- public static String getRequestURI(javax.servlet.http.HttpServletRequest request, boolean excludeMatrixParameters)
request
- excludeMatrixParameters
- public static String getRequestPath(javax.servlet.http.HttpServletRequest request)
request
- public static String getRequestPath(javax.servlet.http.HttpServletRequest request, String characterEncoding)
request
- characterEncoding
- public static String getPathInfo(ResolvedMount mount, javax.servlet.http.HttpServletRequest request)
HttpServletRequest#getRequestURI()
.mount
- request
- public static String getPathInfo(ResolvedMount mount, javax.servlet.http.HttpServletRequest request, String characterEncoding)
Returns any extra path information associated with the URL the client sent when it made this request. The extra path information that comes after the context path and after the (resolved) mountpath but before the query string in the request URL This method extracts and decodes the path information by the specified character encoding parameter from the request URI.
mount
- request
- characterEncoding
- ResolvedMount
but before the query string in the request URLpublic static String[] getRequestHosts(javax.servlet.http.HttpServletRequest request, boolean checkRenderHost)
request
- checkRenderHost
- public static String getRenderingHost(javax.servlet.http.HttpServletRequest request)
request
- the servlet requestpublic static String[] getRequestHosts(javax.servlet.http.HttpServletRequest request)
request
- public static String getFarthestRequestHost(javax.servlet.http.HttpServletRequest request)
request
- public static String getFarthestRequestHost(javax.servlet.http.HttpServletRequest request, boolean checkRenderHost)
checkRenderHost
is true
request
- checkRenderHost
- when true
the optional render host is used when present.checkRenderHost
is true
public static String getFarthestRequestScheme(javax.servlet.http.HttpServletRequest request)
public static String getRequestServerName(javax.servlet.http.HttpServletRequest request)
request
- public static int getRequestServerPort(javax.servlet.http.HttpServletRequest request)
request
- public static String[] getRemoteAddrs(javax.servlet.http.HttpServletRequest request)
request
- public static String getFarthestRemoteAddr(javax.servlet.http.HttpServletRequest request)
request
- public static Map<String,String[]> parseQueryString(javax.servlet.http.HttpServletRequest request)
public static String createURLWithExplicitSchemeForRequest(String scheme, Mount mount, javax.servlet.http.HttpServletRequest request)
scheme
parameter instead of the scheme of the request
.public static String getFullyQualifiedHstURL(HstRequestContext requestContext, HstURL hstUrl, boolean escapeXml)
HstURL
hstUrl
. As scheme for the created url,
always the scheme of the current (farthest) request is taken, as a hstUrl can never have a different scheme than the
request that was used to create the hstUrlCopyright © 2008-2013 Hippo B.V. (http://www.onehippo.com). All Rights Reserved.