public class StubServletRequest extends java.lang.Object implements CauchoRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
Constructor and Description |
---|
StubServletRequest() |
Modifier and Type | Method and Description |
---|---|
void |
addAsyncListener(AsyncListener listener) |
void |
addAsyncListener(AsyncListener listener,
ServletRequest request,
ServletResponse response) |
boolean |
authenticate(HttpServletResponse response) |
void |
clientDisconnect() |
AbstractHttpRequest |
getAbstractHttpRequest() |
AsyncContext |
getAsyncContext()
Returns the async context for the request
|
java.lang.Object |
getAttribute(java.lang.String name)
Returns an attribute value.
|
java.util.Enumeration<java.lang.String> |
getAttributeNames()
Enumerates all attribute names in the request.
|
java.lang.String |
getAuthType()
Returns the auth type, i.e.
|
java.lang.String |
getCharacterEncoding()
Returns the character encoding of the POSTed data.
|
int |
getContentLength()
Returns the content length of the data.
|
java.lang.String |
getContentType()
Returns the request's mime-type.
|
java.lang.String |
getContextPath()
Returns the part of the URI corresponding to the application's
prefix.
|
Cookie |
getCookie(java.lang.String name) |
Cookie[] |
getCookies()
Returns an array of all cookies sent by the client.
|
long |
getDateHeader(java.lang.String header)
Converts a date header to milliseconds since the epoch.
|
DispatcherType |
getDispatcherType()
Returns DispatcherType
|
boolean |
getHasCookie() |
java.lang.String |
getHeader(java.lang.String header)
Returns the first value for a request header.
|
java.util.Enumeration<java.lang.String> |
getHeaderNames()
Returns an enumeration of all headers sent by the client.
|
java.util.Enumeration |
getHeaders(java.lang.String header)
Returns all the values for a request header.
|
ServletInputStream |
getInputStream()
Returns an InputStream to retrieve POST data from the request.
|
int |
getIntHeader(java.lang.String header)
Converts a header value to an integer.
|
java.lang.String |
getLocalAddr()
This call returns the ip of the host actually used to connect to the Resin
server, which means that if ipchains, load balancing, or proxying is
involved this call does not return the correct host for
forming urls.
|
java.util.Locale |
getLocale()
Returns the request's preferred locale, based on the Accept-Language
header.
|
java.util.Enumeration<java.util.Locale> |
getLocales()
Returns an enumeration of all locales acceptable by the client.
|
java.lang.String |
getLocalHost() |
java.lang.String |
getLocalName()
Returns the IP address of the local host, i.e.
|
int |
getLocalPort()
Returns the port of the local host.
|
HttpSession |
getMemorySession() |
java.lang.String |
getMethod()
Returns the HTTP method, e.g.
|
java.lang.String |
getPageContextPath() |
java.lang.String |
getPagePathInfo() |
java.lang.String |
getPageQueryString() |
java.lang.String |
getPageServletPath() |
java.lang.String |
getPageURI() |
java.lang.String |
getParameter(java.lang.String name)
Returns a form parameter.
|
java.util.Map<java.lang.String,java.lang.String[]> |
getParameterMap()
Returns a Map of the form parameters.
|
java.util.Enumeration<java.lang.String> |
getParameterNames()
Returns an enumeration of all form parameter names.
|
java.lang.String[] |
getParameterValues(java.lang.String name)
Returns all values of a form parameter.
|
Part |
getPart(java.lang.String name) |
java.util.Collection<Part> |
getParts() |
java.lang.String |
getPathInfo()
Returns the URI part after the selected servlet and null if there
is no suffix.
|
java.lang.String |
getPathTranslated()
Returns the physical path name for the path info.
|
java.lang.String |
getProtocol()
Returns the prococol, e.g.
|
java.lang.String |
getQueryString()
Returns the request's query string.
|
java.io.BufferedReader |
getReader()
Returns a reader to read POSTed data.
|
java.lang.String |
getRealPath(java.lang.String path)
Returns the path of the URI.
|
java.lang.String |
getRemoteAddr()
Returns the IP address of the remote host, i.e.
|
java.lang.String |
getRemoteHost()
Returns the DNS hostname of the remote host, i.e.
|
int |
getRemotePort()
Returns the port of the remote host, i.e.
|
java.lang.String |
getRemoteUser()
Returns the remote user if authenticated.
|
ServletRequest |
getRequest() |
int |
getRequestDepth(int i) |
RequestDispatcher |
getRequestDispatcher(java.lang.String uri)
Returns a request dispatcher for later inclusion or forwarding.
|
java.lang.String |
getRequestedSessionId()
Returns the session id.
|
java.lang.String |
getRequestURI()
Returns the entire request URI
|
java.lang.StringBuffer |
getRequestURL()
Reconstructs the URL the client used for the request.
|
java.lang.String |
getScheme()
Returns the request scheme, e.g.
|
java.lang.String |
getServerName()
Returns the server name handling the request.
|
int |
getServerPort()
Returns the server port used by the client, e.g.
|
ServletContext |
getServletContext()
Returns the servlet context for the request
|
java.lang.String |
getServletPath()
Returns the URI part corresponding to the selected servlet.
|
ServletResponse |
getServletResponse() |
HttpSession |
getSession()
Returns the current session, creating one if necessary.
|
HttpSession |
getSession(boolean create)
Returns a session.
|
java.lang.String |
getSessionId() |
SocketLink |
getSocketLink() |
ReadStream |
getStream() |
byte[] |
getUriBuffer() |
int |
getUriLength() |
java.security.Principal |
getUserPrincipal()
Returns the equivalent principal object for the authenticated user.
|
boolean |
getVaryCookies() |
WebApp |
getWebApp() |
boolean |
hasRequest() |
boolean |
initStream(ReadStream rawStream,
ReadStream realStream) |
boolean |
isAsyncStarted()
Returns true if the request is in async.
|
boolean |
isAsyncSupported()
Returns true if the request supports async
|
boolean |
isComet() |
boolean |
isConnectionClosed() |
boolean |
isDuplex() |
boolean |
isLoginRequested() |
boolean |
isMultipartEnabled() |
boolean |
isRequestedSessionIdFromCookie()
Returns true if the session came from a cookie.
|
boolean |
isRequestedSessionIdFromUrl() |
boolean |
isRequestedSessionIdFromURL()
Returns true if the session came URL-encoding.
|
boolean |
isRequestedSessionIdValid()
Returns true if the session is valid.
|
boolean |
isSecure()
Returns true if the connection is secure, e.g.
|
boolean |
isSessionIdFromCookie() |
boolean |
isSuspend() |
boolean |
isSyntheticCacheHeader() |
boolean |
isTop() |
boolean |
isUserInRole(java.lang.String str)
Returns true if the user is in the given role.
|
void |
killKeepalive(java.lang.String reason) |
boolean |
login(boolean isFail)
Authenticate the user.
|
void |
login(java.lang.String username,
java.lang.String password) |
void |
logout() |
void |
removeAttribute(java.lang.String name)
Removes the given attribute.
|
void |
requestLogin() |
void |
setAsyncSupported(boolean isAsyncSupported) |
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets an attribute value.
|
void |
setCharacterEncoding(java.lang.String encoding)
Overrides the character encoding specified in the request.
|
void |
setHasCookie() |
void |
setHeader(java.lang.String k,
java.lang.String v) |
void |
setSessionId(java.lang.String sessionId) |
void |
setSyntheticCacheHeader(boolean isSynthetic) |
void |
setVaryCookie(java.lang.String cookie) |
AsyncContext |
startAsync()
Starts an async/comet mode
|
AsyncContext |
startAsync(ServletRequest servletRequest,
ServletResponse servletResponse)
Starts an async mode
|
SocketLinkDuplexController |
upgradeProtocol(SocketLinkDuplexListener handler) |
public java.lang.Object getAttribute(java.lang.String name)
ServletRequest
getAttribute
in interface ServletRequest
name
- the attribute namepublic java.util.Enumeration<java.lang.String> getAttributeNames()
ServletRequest
getAttributeNames
in interface ServletRequest
public void setAttribute(java.lang.String name, java.lang.Object value)
ServletRequest
setAttribute
in interface ServletRequest
name
- the attribute namevalue
- the attribute valuepublic void removeAttribute(java.lang.String name)
ServletRequest
removeAttribute
in interface ServletRequest
name
- the attribute namepublic boolean initStream(ReadStream rawStream, ReadStream realStream)
public java.lang.String getCharacterEncoding()
ServletRequest
getCharacterEncoding
in interface ServletRequest
public void setCharacterEncoding(java.lang.String encoding)
ServletRequest
setCharacterEncoding
must be called before calling
getReader
or reading any parameters.setCharacterEncoding
in interface ServletRequest
public int getContentLength()
ServletRequest
The upshot is, rely on the input stream to end when the data completes.
getContentLength
in interface ServletRequest
public java.lang.String getContentType()
ServletRequest
getContentType
in interface ServletRequest
public java.lang.String getParameter(java.lang.String name)
ServletRequest
getParameter
returns the first.
For example, calling getParameter("a")
with the
the query string a=1&a=2
will return "1".
getParameter
in interface ServletRequest
name
- the form parameter to returnpublic java.util.Enumeration<java.lang.String> getParameterNames()
ServletRequest
Enumeration e = request.getParameterNames();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
out.println(name + ": " + request.getParameter(name));
}
getParameterNames
in interface ServletRequest
public java.lang.String[] getParameterValues(java.lang.String name)
ServletRequest
For example, calling getParameterValues("a")
with the the query string a=1&a=2
will
return ["1", "2"].
getParameterValues
in interface ServletRequest
name
- the form parameter to returnpublic java.util.Map<java.lang.String,java.lang.String[]> getParameterMap()
ServletRequest
getParameterNames
and the values are String arrays as returned by
getParameterValues
.getParameterMap
in interface ServletRequest
public java.lang.String getProtocol()
ServletRequest
getProtocol
in interface ServletRequest
public java.lang.String getRemoteAddr()
ServletRequest
getRemoteAddr
in interface ServletRequest
public java.lang.String getRemoteHost()
ServletRequest
getRemoteHost
in interface ServletRequest
public int getRemotePort()
ServletRequest
getRemotePort
in interface ServletRequest
public java.lang.String getLocalAddr()
ServletRequest
getLocalAddr
in interface ServletRequest
public java.lang.String getLocalHost()
public java.lang.String getLocalName()
ServletRequest
getLocalName
in interface ServletRequest
public int getLocalPort()
ServletRequest
ServletRequest.isSecure()
is provided for that purpose.getLocalPort
in interface ServletRequest
public java.lang.String getScheme()
ServletRequest
getScheme
in interface ServletRequest
public java.lang.String getServerName()
ServletRequest
getServerName
in interface ServletRequest
public int getServerPort()
ServletRequest
ServletRequest.isSecure()
is provided for that purpose.getServerPort
in interface ServletRequest
public java.lang.String getRealPath(java.lang.String path)
ServletRequest
getRealPath
in interface ServletRequest
public java.util.Locale getLocale()
ServletRequest
getLocale
in interface ServletRequest
public java.util.Enumeration<java.util.Locale> getLocales()
ServletRequest
getLocales
in interface ServletRequest
public boolean isSecure()
ServletRequest
isSecure
in interface ServletRequest
public RequestDispatcher getRequestDispatcher(java.lang.String uri)
ServletRequest
uri
is relative to the request URI. Absolute URIs are relative to
the application prefix (getContextPath()
).
If getRequestURI()
is /myapp/dir/test.jsp and the
uri
is "inc.jsp", the resulting page is
/myapp/dir/inc.jsp.
RequestDispatcher disp;
disp = getRequestDispatcher("inc.jsp?a=b");
disp.include(request, response);
getRequestDispatcher
in interface ServletRequest
uri
- path relative to getRequestURI()
(including query string) for the included file.public java.lang.String getMethod()
HttpServletRequest
REQUEST_METHOD
getMethod
in interface HttpServletRequest
public java.lang.String getServletPath()
HttpServletRequest
SCRIPT_NAME
getServletPath()
is /servlet/Hello for the uri
/myapp/servlet/Hello/foo.
getServletPath()
is /dir/hello.jsp
for the uri /myapp/dir/hello.jsp/foo,getServletPath
in interface HttpServletRequest
public java.lang.String getContextPath()
HttpServletRequest
getContextPath()
is /myapp for the uri
/myapp/servlet/Hello,
getContextPath
in interface HttpServletRequest
public java.lang.String getPathInfo()
HttpServletRequest
PATH_INFO
getPathInfo()
is /foo for
the uri /myapp/servlet/Hello/foo.
getPathInfo()
is /hello.jsp for for the uri
/myapp/dir/hello.jsp/foo.
getPathInfo
in interface HttpServletRequest
public java.lang.String getPathTranslated()
HttpServletRequest
PATH_TRANSLATED
getPathTranslated
in interface HttpServletRequest
public java.lang.String getRequestURI()
HttpServletRequest
getRequestURI
in interface HttpServletRequest
public java.lang.StringBuffer getRequestURL()
HttpServletRequest
getRequestURL
in interface HttpServletRequest
public int getUriLength()
public byte[] getUriBuffer()
public java.lang.String getQueryString()
HttpServletRequest
ServletRequest.getParameter()
to decode the form values.
Corresponds to CGI's PATH_TRANSLATED
getQueryString
in interface HttpServletRequest
public java.lang.String getPageURI()
getPageURI
in interface CauchoRequest
public java.lang.String getPageContextPath()
getPageContextPath
in interface CauchoRequest
public java.lang.String getPageServletPath()
getPageServletPath
in interface CauchoRequest
public java.lang.String getPagePathInfo()
getPagePathInfo
in interface CauchoRequest
public java.lang.String getPageQueryString()
getPageQueryString
in interface CauchoRequest
public java.lang.String getHeader(java.lang.String header)
HttpServletRequest
HTTP_*
String userAgent = request.getHeader("User-Agent");
getHeader
in interface HttpServletRequest
header
- the header namepublic int getIntHeader(java.lang.String header)
HttpServletRequest
getIntHeader
in interface HttpServletRequest
header
- the header namepublic long getDateHeader(java.lang.String header)
HttpServletRequest
long mod = request.getDateHeader("If-Modified-Since");
getDateHeader
in interface HttpServletRequest
header
- the header namepublic java.util.Enumeration getHeaders(java.lang.String header)
HttpServletRequest
getHeaders
in interface HttpServletRequest
header
- the header namepublic java.util.Enumeration<java.lang.String> getHeaderNames()
HttpServletRequest
getHeaderNames
in interface HttpServletRequest
public java.lang.String getAuthType()
HttpServletRequest
getAuthType
in interface HttpServletRequest
public java.lang.String getRemoteUser()
HttpServletRequest
getRemoteUser
in interface HttpServletRequest
public java.security.Principal getUserPrincipal()
HttpServletRequest
getUserPrincipal
in interface HttpServletRequest
public boolean isUserInRole(java.lang.String str)
HttpServletRequest
isUserInRole
in interface HttpServletRequest
public SocketLinkDuplexController upgradeProtocol(SocketLinkDuplexListener handler)
public AbstractHttpRequest getAbstractHttpRequest()
getAbstractHttpRequest
in interface CauchoRequest
public ServletRequest getRequest()
public ServletResponse getServletResponse()
getServletResponse
in interface CauchoRequest
public boolean login(boolean isFail)
login
in interface CauchoRequest
public boolean isLoginRequested()
isLoginRequested
in interface CauchoRequest
public void requestLogin()
requestLogin
in interface CauchoRequest
public boolean isConnectionClosed()
isConnectionClosed
in interface CauchoRequest
public void clientDisconnect()
public boolean isDuplex()
isDuplex
in interface CauchoRequest
public boolean isComet()
isComet
in interface CauchoRequest
public boolean isSuspend()
isSuspend
in interface CauchoRequest
public void killKeepalive(java.lang.String reason)
killKeepalive
in interface CauchoRequest
public void setHasCookie()
setHasCookie
in interface CauchoRequest
public Cookie getCookie(java.lang.String name)
getCookie
in interface CauchoRequest
public HttpSession getMemorySession()
getMemorySession
in interface CauchoRequest
public boolean hasRequest()
hasRequest
in interface CauchoRequest
public boolean isTop()
isTop
in interface CauchoRequest
public boolean getHasCookie()
getHasCookie
in interface CauchoRequest
public void setVaryCookie(java.lang.String cookie)
setVaryCookie
in interface CauchoRequest
public boolean getVaryCookies()
getVaryCookies
in interface CauchoRequest
public void setHeader(java.lang.String k, java.lang.String v)
setHeader
in interface CauchoRequest
public int getRequestDepth(int i)
getRequestDepth
in interface CauchoRequest
public ReadStream getStream()
getStream
in interface CauchoRequest
public WebApp getWebApp()
getWebApp
in interface CauchoRequest
public java.util.Collection<Part> getParts() throws java.io.IOException, ServletException
getParts
in interface HttpServletRequest
java.io.IOException
ServletException
public Part getPart(java.lang.String name) throws java.io.IOException, ServletException
getPart
in interface HttpServletRequest
java.io.IOException
ServletException
public boolean isMultipartEnabled()
isMultipartEnabled
in interface CauchoRequest
public boolean authenticate(HttpServletResponse response) throws java.io.IOException, ServletException
authenticate
in interface HttpServletRequest
java.io.IOException
ServletException
public void login(java.lang.String username, java.lang.String password) throws ServletException
login
in interface HttpServletRequest
ServletException
public void logout() throws ServletException
logout
in interface HttpServletRequest
ServletException
public boolean isRequestedSessionIdValid()
HttpServletRequest
isRequestedSessionIdValid
in interface HttpServletRequest
public boolean isRequestedSessionIdFromCookie()
HttpServletRequest
isRequestedSessionIdFromCookie
in interface HttpServletRequest
public boolean isRequestedSessionIdFromURL()
HttpServletRequest
isRequestedSessionIdFromURL
in interface HttpServletRequest
public boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl
in interface HttpServletRequest
public java.lang.String getRequestedSessionId()
HttpServletRequest
getRequestedSessionId
in interface HttpServletRequest
public HttpSession getSession()
HttpServletRequest
getSession
in interface HttpServletRequest
public HttpSession getSession(boolean create)
HttpServletRequest
getSession
in interface HttpServletRequest
create
- If true, then create a new session if none exists.public Cookie[] getCookies()
HttpServletRequest
getCookies
in interface HttpServletRequest
public boolean isSyntheticCacheHeader()
isSyntheticCacheHeader
in interface CauchoRequest
public void setSyntheticCacheHeader(boolean isSynthetic)
setSyntheticCacheHeader
in interface CauchoRequest
public DispatcherType getDispatcherType()
ServletRequest
getDispatcherType
in interface ServletRequest
public void addAsyncListener(AsyncListener listener)
public void addAsyncListener(AsyncListener listener, ServletRequest request, ServletResponse response)
public AsyncContext getAsyncContext()
ServletRequest
getAsyncContext
in interface ServletRequest
public ServletContext getServletContext()
ServletRequest
getServletContext
in interface ServletRequest
public boolean isAsyncStarted()
ServletRequest
isAsyncStarted
in interface ServletRequest
public boolean isAsyncSupported()
ServletRequest
isAsyncSupported
in interface ServletRequest
public void setAsyncSupported(boolean isAsyncSupported)
public AsyncContext startAsync() throws java.lang.IllegalStateException
ServletRequest
startAsync
in interface ServletRequest
java.lang.IllegalStateException
public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws java.lang.IllegalStateException
ServletRequest
startAsync
in interface ServletRequest
java.lang.IllegalStateException
public java.io.BufferedReader getReader() throws java.io.IOException, java.lang.IllegalStateException
ServletRequest
getCharacterEncoding()
getReader
in interface ServletRequest
java.io.IOException
java.lang.IllegalStateException
public ServletInputStream getInputStream() throws java.io.IOException
ServletRequest
getInputStream
in interface ServletRequest
java.io.IOException
public boolean isSessionIdFromCookie()
isSessionIdFromCookie
in interface CauchoRequest
public java.lang.String getSessionId()
getSessionId
in interface CauchoRequest
public void setSessionId(java.lang.String sessionId)
setSessionId
in interface CauchoRequest
public SocketLink getSocketLink()
getSocketLink
in interface CauchoRequest