@Beta public final class HttpServletSupport extends Object
| Modifier | Constructor and Description |
|---|---|
private |
HttpServletSupport()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addNoCacheHeaders(javax.servlet.http.HttpServletResponse response)
Adds Cache-Control and Pragma headers meant to disable caching.
|
static URI |
getFullRequestURI(javax.servlet.http.HttpServletRequest request)
Gets the URL that was requested to generate this request.
|
static String |
getRequestPathWithoutContext(javax.servlet.http.HttpServletRequest request)
Gets the request URI as returned by
HttpServletRequest.getRequestURI() but without the servlet context
path. |
static void |
setContentType(javax.servlet.http.HttpServletResponse response,
String contentType)
Sets the MIME content type of the response.
|
static void |
setUTF8Encoding(javax.servlet.http.HttpServletResponse response)
Sets the character encoding of the transport to UTF-8.
|
static boolean |
validateContentType(javax.servlet.http.HttpServletRequest request,
Set<com.google.common.net.MediaType> validTypes,
boolean noContentTypeIsValid,
boolean isOneOfStrategy)
Validate the Content-Type of the specified request.
|
public static void addNoCacheHeaders(javax.servlet.http.HttpServletResponse response)
response - transport to add headers topublic static void setUTF8Encoding(javax.servlet.http.HttpServletResponse response)
response - transport to set character encoding typepublic static void setContentType(javax.servlet.http.HttpServletResponse response,
String contentType)
response - the transport to set content type oncontentType - the content type to setpublic static String getRequestPathWithoutContext(javax.servlet.http.HttpServletRequest request)
HttpServletRequest.getRequestURI() but without the servlet context
path.request - request to get the URI frompublic static URI getFullRequestURI(javax.servlet.http.HttpServletRequest request)
request - current requestpublic static boolean validateContentType(javax.servlet.http.HttpServletRequest request,
Set<com.google.common.net.MediaType> validTypes,
boolean noContentTypeIsValid,
boolean isOneOfStrategy)
2 strategies are supported for evaluating the request's parsed content type:
MediaType parsed from the request is compared to each
of the specified valid types via MediaType.is(MediaType). If any pass, the type is considered
valid. This allows use of MediaType's support for wildcard and parameter evaluation.
MediaType parsed from the request is stripped
of its parameters, as is each of the valid types. Then a simple evaluation is done that the
request type is equal to one of the passed types. In this case, only literal types and subtypes
should be passed as valid types; wildcards should not be used.
request - the request to be validatedvalidTypes - the set of valid media typesnoContentTypeIsValid - flag whether the case of a missing/empty Content-Type header is considered validisOneOfStrategy - flag for the strategy used in the validation (see above for details)Copyright © 1999–2020 Shibboleth Consortium. All rights reserved.