public class HstRequestUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
HTTP_METHOD_POST |
static Pattern |
MATRIX_PARAMS_PATTERN |
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 |
getCharacterEncoding(javax.servlet.http.HttpServletRequest request)
Returns the name of the character encoding used in the body of the servlet request.
|
static String |
getCharacterEncoding(javax.servlet.http.HttpServletRequest request,
String defaultEncoding)
Returns the name of the character encoding used in the body of the servlet request.
|
static String |
getExternalRequestUrl(javax.servlet.http.HttpServletRequest request,
boolean includeQueryString)
Returns the request URL as seen by, for example, a browser.
|
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)
Deprecated.
since CMS 7.9.1 (2.28.05) use
HttpServletRequest.getPathInfo() instead |
static String |
getPathInfo(ResolvedMount mount,
javax.servlet.http.HttpServletRequest request,
String characterEncoding)
Deprecated.
since CMS 7.9.1 (2.28.05) use
HttpServletRequest.getPathInfo() instead |
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 boolean |
isComponentRenderingPreviewRequest(HstRequestContext requestContext) |
static Map<String,String[]> |
parseQueryString(javax.servlet.http.HttpServletRequest request) |
static Map<String,String[]> |
parseQueryString(URI uri,
String encoding) |
static String |
removeAllMatrixParams(String uri) |
public static final Pattern MATRIX_PARAMS_PATTERN
public static final String HTTP_METHOD_POST
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
- @Deprecated public static String getPathInfo(ResolvedMount mount, javax.servlet.http.HttpServletRequest request)
HttpServletRequest.getPathInfo()
instead@Deprecated public static String getPathInfo(ResolvedMount mount, javax.servlet.http.HttpServletRequest request, String characterEncoding)
HttpServletRequest.getPathInfo()
insteadpublic 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 String getCharacterEncoding(javax.servlet.http.HttpServletRequest request)
ISO-8859-1
instead of null if the request does not specify a character encoding
because the Servlet specification requires that an encoding of ISO-8859-1 is used if a character encoding is not specified.request
- public static String getCharacterEncoding(javax.servlet.http.HttpServletRequest request, String defaultEncoding)
defaultEncoding
instead of null if the request does not specify a character encoding.request
- defaultEncoding
- public static Map<String,String[]> parseQueryString(javax.servlet.http.HttpServletRequest request)
public static Map<String,String[]> parseQueryString(URI uri, String encoding) throws UnsupportedEncodingException
UnsupportedEncodingException
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 hstUrlpublic static String escapeXml(String str)
str
- - the String where to replacepublic static boolean isComponentRenderingPreviewRequest(HstRequestContext requestContext)
true
if the request is a preview component rendering request from channel manager in cmspublic static String getExternalRequestUrl(javax.servlet.http.HttpServletRequest request, boolean includeQueryString)
VirtualHost.getBaseURL(javax.servlet.http.HttpServletRequest)
VirtualHost.isContextPathInUrl()
)includeQueryString
, the queryString is addedrequest
- the HTTP servlet requestincludeQueryString
- whether to include the queryString as seen by the browserCopyright © 2008–2016 Hippo B.V. (http://www.onehippo.com). All rights reserved.