public class EntityHttpServletRequest extends Object implements HttpServletRequest
| Modifier and Type | Class and Description |
|---|---|
static class |
EntityHttpServletRequest.EntityHttpSession
A fake session for testing, from the spring mock session
|
static class |
EntityHttpServletRequest.EntityRequestDispatcher
A non-functional request dispatcher, based on the spring mock version
|
static class |
EntityHttpServletRequest.EntityServletContext
For testing, based on the spring Mock version
|
| Modifier and Type | Field and Description |
|---|---|
HttpServletRequest |
copy |
static String |
DEFAULT_PROTOCOL
default protocol: HTTP/1.0
|
static String |
DEFAULT_REMOTE_ADDR
default remote address: 127.0.0.1
|
static String |
DEFAULT_REMOTE_HOST
The default remote host: 'localhost'.
|
static String |
DEFAULT_SCHEMA
default schema: http
|
static String |
DEFAULT_SERVER_ADDR
default server address: 127.0.0.1
|
static String |
DEFAULT_SERVER_NAME
default server name: localhost
|
static int |
DEFAULT_SERVER_PORT
default server port: 80
|
Map<String,String[]> |
pathQueryParams
This stores all the query params found when the request was created
|
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH| Constructor and Description |
|---|
EntityHttpServletRequest(HttpServletRequest req)
Create a new request from a given request
|
EntityHttpServletRequest(HttpServletRequest req,
String pathString)
Create a new request from a given request and modify it based on the path string
|
EntityHttpServletRequest(HttpServletRequest req,
String method,
String pathString)
Create a new request from a given request and modify it based on the path string and method
|
EntityHttpServletRequest(String pathString)
Create a request using the pathString
|
EntityHttpServletRequest(String method,
String pathString)
Create a request using the pathString and setting the method
|
EntityHttpServletRequest(String method,
String pathString,
String... params)
Create a request using the pathString and setting the method and params
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCookie(Cookie cookie)
Adds a new cookie to the request
|
void |
addHeader(String name,
String... content) |
void |
addParameter(String name,
String value)
Add a single parameter,
this will append to an existing one
|
void |
addParameter(String name,
String[] values)
Add an array of values for a parameter,
these will append to existing ones
|
void |
clearAttributes()
Remove all attributes
|
void |
clearCookies()
Remove all cookies
|
void |
clearHeaders()
Remove all headers
|
void |
clearParameters()
Remove all parameters
|
Object |
getAttribute(String name) |
Enumeration |
getAttributeNames() |
String |
getAuthType() |
String |
getCharacterEncoding() |
ServletInputStream |
getContent()
Gets the content data out of the request, ensures that the data can be retrieved somehow
|
int |
getContentLength() |
String |
getContentType() |
String |
getContextPath() |
Cookie[] |
getCookies() |
long |
getDateHeader(String name) |
String |
getHeader(String name) |
Enumeration |
getHeaderNames() |
Enumeration |
getHeaders(String name) |
ServletInputStream |
getInputStream() |
int |
getIntHeader(String name) |
String |
getLocalAddr() |
Locale |
getLocale() |
Enumeration |
getLocales() |
String |
getLocalName() |
int |
getLocalPort() |
String |
getMethod() |
String |
getParameter(String name) |
Map |
getParameterMap() |
Enumeration |
getParameterNames() |
Map<String,String[]> |
getParameters() |
String[] |
getParameterValues(String name) |
String |
getPathInfo() |
String |
getPathTranslated() |
String |
getProtocol() |
String |
getQueryString() |
BufferedReader |
getReader() |
String |
getRealPath(String path) |
String |
getRemoteAddr() |
String |
getRemoteHost() |
int |
getRemotePort() |
String |
getRemoteUser() |
RequestDispatcher |
getRequestDispatcher(String path) |
String |
getRequestedSessionId() |
String |
getRequestURI() |
StringBuffer |
getRequestURL() |
String |
getScheme() |
String |
getServerName() |
int |
getServerPort() |
String |
getServletPath() |
HttpSession |
getSession() |
HttpSession |
getSession(boolean create) |
Map<String,String> |
getStringParameters() |
Principal |
getUserPrincipal() |
boolean |
isRequestedSessionIdFromCookie() |
boolean |
isRequestedSessionIdFromUrl() |
boolean |
isRequestedSessionIdFromURL() |
boolean |
isRequestedSessionIdValid() |
boolean |
isSecure() |
boolean |
isUserInRole(String role) |
void |
removeAttribute(String name) |
void |
removeCookie(String name)
Removes the cookie with the given name from the request
|
void |
removeHeader(String name) |
void |
removeParameter(String name)
Removes a parameter and all values for it
|
void |
setAttribute(String name,
Object o) |
void |
setCharacterEncoding(String env) |
void |
setContent(byte[] content)
Allows control over the content data which is used in this request,
all data should be UTF-8 encoded
|
void |
setContent(InputStream contentStream,
int contentLength)
Allows control over the content data which is used in this request,
all data should be UTF-8 encoded
|
void |
setContent(String content)
Allows control over the content data which is used in this request,
all data should be UTF-8 encoded
|
void |
setContentType(String contentType)
Sets the content type for this request content
|
void |
setContextPath(String contextPath) |
void |
setLocale(Locale locale) |
void |
setMethod(String method) |
void |
setParameter(String name,
String[] values)
Set a new parameter (overwrite an existing one)
|
void |
setParameters(Map<String,String[]> params)
Set a large number of params at once,
replaces existing params
|
void |
setPathInfo(String pathInfo) |
URLData |
setPathString(String pathString)
This will set the given url/path string values into this request,
this will override any values that are currently set
|
void |
setQueryString(String queryString) |
void |
setRequestValues(HttpServletRequest req)
Set all the values from a request on this request object and set this request
as the one which the values were copied from
|
void |
setServletPath(String servletPath) |
void |
setUseRealDispatcher(boolean real) |
String |
toString() |
public static final String DEFAULT_SCHEMA
public static final String DEFAULT_PROTOCOL
public static final String DEFAULT_SERVER_ADDR
public static final String DEFAULT_SERVER_NAME
public static final int DEFAULT_SERVER_PORT
public static final String DEFAULT_REMOTE_ADDR
public static final String DEFAULT_REMOTE_HOST
public HttpServletRequest copy
public EntityHttpServletRequest(HttpServletRequest req)
req - any requestpublic EntityHttpServletRequest(HttpServletRequest req, String pathString)
req - any requestpathString - any full path or URL (/direct/prefix/id.xml)public EntityHttpServletRequest(HttpServletRequest req, String method, String pathString)
req - any requestmethod - GET, POST, PUT, DELETE (PUT and DELETE not supported by browsers),
this will be set to POST if null or unsetpathString - any full path or URL (/direct/prefix/id.xml)public EntityHttpServletRequest(String pathString)
pathString - any path or URLpublic EntityHttpServletRequest(String method, String pathString)
pathString - any path or URLmethod - GET, POST, PUT, DELETE (PUT and DELETE not supported by browsers),
this will be set to POST if null or unsetpublic EntityHttpServletRequest(String method, String pathString, String... params)
method - GET, POST, PUT, DELETE (PUT and DELETE not supported by browsers),
this will be set to POST if null or unsetpathString - any path or URLparams - alternating keys and values (starting with keys) to place into the request parameterspublic void setRequestValues(HttpServletRequest req)
req - any requestpublic URLData setPathString(String pathString)
pathString - any url or path stringpublic void setContent(InputStream contentStream, int contentLength)
content - any IS content, UTF-8 encoded, replaces existing contentpublic void setContent(byte[] content)
content - any byte[] content, UTF-8 encoded, replaces existing contentpublic void setContent(String content)
content - any string content, UTF-8 encoded, replaces existing contentpublic ServletInputStream getContent() throws IOException
IOException - if there is a failurepublic Object getAttribute(String name)
getAttribute in interface ServletRequestpublic Enumeration getAttributeNames()
getAttributeNames in interface ServletRequestpublic void removeAttribute(String name)
removeAttribute in interface ServletRequestpublic void setAttribute(String name, Object o)
setAttribute in interface ServletRequestpublic void clearAttributes()
public void setCharacterEncoding(String env) throws UnsupportedEncodingException
setCharacterEncoding in interface ServletRequestUnsupportedEncodingExceptionpublic String getCharacterEncoding()
getCharacterEncoding in interface ServletRequestpublic void setContentType(String contentType)
contentType - public String getContentType()
getContentType in interface ServletRequestpublic int getContentLength()
getContentLength in interface ServletRequestpublic ServletInputStream getInputStream() throws IOException
getInputStream in interface ServletRequestIOExceptionpublic BufferedReader getReader() throws IOException
getReader in interface ServletRequestIOExceptionpublic void setLocale(Locale locale)
public Locale getLocale()
getLocale in interface ServletRequestpublic void setMethod(String method)
public String getMethod()
getMethod in interface HttpServletRequestpublic void setContextPath(String contextPath)
public String getContextPath()
getContextPath in interface HttpServletRequestpublic void setPathInfo(String pathInfo)
public String getPathInfo()
getPathInfo in interface HttpServletRequestpublic String getPathTranslated()
getPathTranslated in interface HttpServletRequestpublic void setQueryString(String queryString)
public String getQueryString()
getQueryString in interface HttpServletRequestpublic String getRequestURI()
getRequestURI in interface HttpServletRequestpublic StringBuffer getRequestURL()
getRequestURL in interface HttpServletRequestpublic void setServletPath(String servletPath)
public String getServletPath()
getServletPath in interface HttpServletRequestpublic void addCookie(Cookie cookie)
cookie - a cookie to add, will displace existing cookies with the same namepublic void removeCookie(String name)
name - the name of a cookiepublic Cookie[] getCookies()
getCookies in interface HttpServletRequestpublic void clearCookies()
public void removeHeader(String name)
public String getHeader(String name)
getHeader in interface HttpServletRequestpublic Enumeration getHeaderNames()
getHeaderNames in interface HttpServletRequestpublic Enumeration getHeaders(String name)
getHeaders in interface HttpServletRequestpublic long getDateHeader(String name)
getDateHeader in interface HttpServletRequestpublic int getIntHeader(String name)
getIntHeader in interface HttpServletRequestpublic void clearHeaders()
public String getAuthType()
getAuthType in interface HttpServletRequestpublic String getLocalAddr()
getLocalAddr in interface ServletRequestpublic Enumeration getLocales()
getLocales in interface ServletRequestpublic String getLocalName()
getLocalName in interface ServletRequestpublic int getLocalPort()
getLocalPort in interface ServletRequestpublic Map<String,String> getStringParameters()
public String getParameter(String name)
getParameter in interface ServletRequestpublic Map getParameterMap()
getParameterMap in interface ServletRequestpublic Enumeration getParameterNames()
getParameterNames in interface ServletRequestpublic String[] getParameterValues(String name)
getParameterValues in interface ServletRequestpublic void addParameter(String name, String value)
public void addParameter(String name, String[] values)
public void setParameter(String name, String[] values)
public void setParameters(Map<String,String[]> params)
params - map of paramspublic void removeParameter(String name)
name - public void clearParameters()
public String getProtocol()
getProtocol in interface ServletRequestpublic String getRealPath(String path)
getRealPath in interface ServletRequestpublic String getRemoteAddr()
getRemoteAddr in interface ServletRequestpublic String getRemoteHost()
getRemoteHost in interface ServletRequestpublic int getRemotePort()
getRemotePort in interface ServletRequestpublic String getRemoteUser()
getRemoteUser in interface HttpServletRequestpublic void setUseRealDispatcher(boolean real)
real - if true and there is a real RequestDispatcher available then use it,
otherwise just emulate a forward/include call using the fake one
(will always use the fake one if no real one is found)public RequestDispatcher getRequestDispatcher(String path)
getRequestDispatcher in interface ServletRequestpublic String getScheme()
getScheme in interface ServletRequestpublic String getServerName()
getServerName in interface ServletRequestpublic int getServerPort()
getServerPort in interface ServletRequestpublic String getRequestedSessionId()
getRequestedSessionId in interface HttpServletRequestpublic HttpSession getSession()
getSession in interface HttpServletRequestpublic HttpSession getSession(boolean create)
getSession in interface HttpServletRequestpublic Principal getUserPrincipal()
getUserPrincipal in interface HttpServletRequestpublic boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie in interface HttpServletRequestpublic boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl in interface HttpServletRequestpublic boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL in interface HttpServletRequestpublic boolean isRequestedSessionIdValid()
isRequestedSessionIdValid in interface HttpServletRequestpublic boolean isSecure()
isSecure in interface ServletRequestpublic boolean isUserInRole(String role)
isUserInRole in interface HttpServletRequestCopyright © 2007-2014 CARET, University of Cambridge. All Rights Reserved.