public final class ServletUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
DATA_URI_KEY |
static String |
REMOTE_ADDR_KEY |
| Modifier and Type | Method and Description |
|---|---|
static HttpResponse |
convertToJsonResponse(HttpResponse response)
Converts the given
HttpResponse into JSON form, with at least
one field, dataUri, containing a Data URI that can be inlined into an HTML page. |
static void |
copyContentToServletResponse(HttpResponse response,
javax.servlet.http.HttpServletResponse servletResponse) |
static void |
copyHeadersAndStatusToServletResponse(HttpResponse response,
javax.servlet.http.HttpServletResponse servletResponse) |
static void |
copyToServletResponse(HttpResponse response,
javax.servlet.http.HttpServletResponse servletResponse) |
static void |
copyToServletResponseAndOverrideCacheHeaders(HttpResponse response,
javax.servlet.http.HttpServletResponse servletResponse) |
static HttpResponse |
errorResponse(GadgetException e) |
static HttpRequest |
fromHttpServletRequest(javax.servlet.http.HttpServletRequest servletReq)
Returns an HttpRequest object encapsulating the servlet request.
|
static void |
setCachingHeaders(HttpResponseBuilder response,
int ttl,
boolean noProxy) |
static void |
setXForwardedForHeader(HttpRequest inboundRequest,
HttpRequest req)
Sets standard forwarding headers on the proxied request.
|
static void |
setXForwardedForHeader(javax.servlet.http.HttpServletRequest inboundRequest,
HttpRequest req) |
static Uri |
validateUrl(Uri urlToValidate)
Validates and normalizes the given url, ensuring that it is non-null, has
scheme http or https, and has a path value of some kind.
|
public static final String REMOTE_ADDR_KEY
public static final String DATA_URI_KEY
public static HttpRequest fromHttpServletRequest(javax.servlet.http.HttpServletRequest servletReq) throws IOException
servletReq - The http servlet request.IOException - In case of errors.public static void setCachingHeaders(HttpResponseBuilder response, int ttl, boolean noProxy)
public static void copyToServletResponseAndOverrideCacheHeaders(HttpResponse response, javax.servlet.http.HttpServletResponse servletResponse) throws IOException
IOExceptionpublic static void copyToServletResponse(HttpResponse response, javax.servlet.http.HttpServletResponse servletResponse) throws IOException
IOExceptionpublic static void copyContentToServletResponse(HttpResponse response, javax.servlet.http.HttpServletResponse servletResponse) throws IOException
IOExceptionpublic static void copyHeadersAndStatusToServletResponse(HttpResponse response, javax.servlet.http.HttpServletResponse servletResponse)
public static Uri validateUrl(Uri urlToValidate) throws GadgetException
GadgetException - If the url is not valid.public static void setXForwardedForHeader(HttpRequest inboundRequest, HttpRequest req) throws GadgetException
inboundRequest - req - GadgetExceptionpublic static void setXForwardedForHeader(javax.servlet.http.HttpServletRequest inboundRequest,
HttpRequest req)
public static HttpResponse errorResponse(GadgetException e)
public static HttpResponse convertToJsonResponse(HttpResponse response) throws IOException
HttpResponse into JSON form, with at least
one field, dataUri, containing a Data URI that can be inlined into an HTML page.
Any metadata on the given HttpResponse is also added as fields.response - Input HttpResponse to convert to JSON.IOException - If there are problems reading from response.Copyright © 2007-2014 The Apache Software Foundation. All Rights Reserved.