public final class HttpUtil extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkFor304(javax.servlet.http.HttpServletRequest req,
java.lang.String pageName,
java.util.Date lastModified)
If returns true, then should return a 304 (HTTP_NOT_MODIFIED)
|
static void |
clearCookie(javax.servlet.http.HttpServletResponse response,
java.lang.String cookieName) |
static java.lang.String |
createETag(java.lang.String pageName,
java.util.Date lastModified)
Creates an ETag based on page information.
|
static java.lang.String |
getRemoteAddress(javax.servlet.http.HttpServletRequest req)
returns the remote address by looking into
x-forwarded-for header or, if unavailable,
into ServletRequest.getRemoteAddr(). |
static java.lang.String |
guessValidURI(java.lang.String uri)
Attempts to form a valid URI based on the string given.
|
static boolean |
isIPV4Address(java.lang.String name)
Verifies whether a String represents an IPv4 address.
|
static java.lang.String |
retrieveCookieValue(javax.servlet.http.HttpServletRequest request,
java.lang.String cookieName)
Attempts to retrieve the given cookie value from the request.
|
static java.lang.String |
safeGetQueryString(javax.servlet.http.HttpServletRequest request,
java.nio.charset.Charset contentEncoding)
Returns the query string (the portion after the question mark).
|
public static java.lang.String getRemoteAddress(javax.servlet.http.HttpServletRequest req)
x-forwarded-for header or, if unavailable,
into ServletRequest.getRemoteAddr().req - http requestpublic static java.lang.String retrieveCookieValue(javax.servlet.http.HttpServletRequest request, java.lang.String cookieName)
request - The current requestcookieName - The name of the cookie to fetch.public static java.lang.String createETag(java.lang.String pageName, java.util.Date lastModified)
pageName - The page name for which the ETag should be created.lastModified - The page last modified date for which the ETag should be created.public static boolean checkFor304(javax.servlet.http.HttpServletRequest req, java.lang.String pageName, java.util.Date lastModified)
req - the HTTP requestpageName - the wiki page name to check forlastModified - the last modified date of the wiki page to check forpublic static java.lang.String guessValidURI(java.lang.String uri)
uri - URI to take a poke atpublic static java.lang.String safeGetQueryString(javax.servlet.http.HttpServletRequest request, java.nio.charset.Charset contentEncoding)
request - The HTTP request to parse.public static boolean isIPV4Address(java.lang.String name)
name - the address to testpublic static void clearCookie(javax.servlet.http.HttpServletResponse response, java.lang.String cookieName)
Copyright (c) 2001-2022 The Apache Software Foundation. All rights reserved.