public class Request extends Object implements HttpServletRequest
Implements HttpServletRequest
from the javax.servlet.http
package.
The standard interface of mostly getters, is extended with setters so that the request is mutable by the handlers that it is passed to. This allows the request object to be as lightweight as possible and not actually implement any significant behavior. For example
getContextPath()
method will return null, until the request has been passed to a ContextHandler
which matches the
getPathInfo()
with a context path and calls setContextPath(String)
as a result.SessionHandler
which checks for session cookies and enables the ability to create new sessions.getServletPath()
method will return null until the request has been passed to a org.eclipse.jetty.servlet.ServletHandler
and the pathInfo matched against the servlet URL patterns and setServletPath(String)
called as a result.
The form content that a request can process is limited to protect from Denial of Service attacks. The size in bytes is limited by
ContextHandler.getMaxFormContentSize()
or if there is no context then the "org.eclipse.jetty.server.Request.maxFormContentSize" Server
attribute. The number of parameters keys is limited by ContextHandler.getMaxFormKeys()
or if there is no context then the
"org.eclipse.jetty.server.Request.maxFormKeys" Server
attribute.
Modifier and Type | Class and Description |
---|---|
static class |
Request.MultiPartCleanerListener |
Modifier and Type | Field and Description |
---|---|
static String |
__MULTIPART_CONFIG_ELEMENT |
static String |
__MULTIPART_CONTEXT |
static String |
__MULTIPART_INPUT_STREAM |
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
Constructor and Description |
---|
Request(HttpChannel<?> channel,
HttpInput<?> input) |
public static final String __MULTIPART_CONFIG_ELEMENT
public static final String __MULTIPART_INPUT_STREAM
public static final String __MULTIPART_CONTEXT
public Request(HttpChannel<?> channel, HttpInput<?> input)
public HttpFields getHttpFields()
public HttpInput<?> getHttpInput()
public void addEventListener(EventListener listener)
public void extractParameters()
public AsyncContext getAsyncContext()
getAsyncContext
in interface ServletRequest
public HttpChannelState getHttpChannelState()
public Object getAttribute(String name)
Also supports jetty specific attributes to gain access to Jetty APIs:
getAttribute
in interface ServletRequest
ServletRequest.getAttribute(java.lang.String)
public Enumeration<String> getAttributeNames()
getAttributeNames
in interface ServletRequest
public Attributes getAttributes()
public Authentication getAuthentication()
public String getAuthType()
getAuthType
in interface HttpServletRequest
public String getCharacterEncoding()
getCharacterEncoding
in interface ServletRequest
public HttpChannel<?> getHttpChannel()
public int getContentLength()
getContentLength
in interface ServletRequest
public long getContentLengthLong()
getContentLengthLong
in interface ServletRequest
public long getContentRead()
public String getContentType()
getContentType
in interface ServletRequest
public ContextHandler.Context getContext()
context
used for this request, or null
if setContext(org.eclipse.jetty.server.handler.ContextHandler.Context)
has not yet been called.public String getContextPath()
getContextPath
in interface HttpServletRequest
public Cookie[] getCookies()
getCookies
in interface HttpServletRequest
public long getDateHeader(String name)
getDateHeader
in interface HttpServletRequest
public DispatcherType getDispatcherType()
getDispatcherType
in interface ServletRequest
public String getHeader(String name)
getHeader
in interface HttpServletRequest
public Enumeration<String> getHeaderNames()
getHeaderNames
in interface HttpServletRequest
public Enumeration<String> getHeaders(String name)
getHeaders
in interface HttpServletRequest
public int getInputState()
public ServletInputStream getInputStream() throws IOException
getInputStream
in interface ServletRequest
IOException
public int getIntHeader(String name)
getIntHeader
in interface HttpServletRequest
public Locale getLocale()
getLocale
in interface ServletRequest
public Enumeration<Locale> getLocales()
getLocales
in interface ServletRequest
public String getLocalAddr()
getLocalAddr
in interface ServletRequest
public String getLocalName()
getLocalName
in interface ServletRequest
public int getLocalPort()
getLocalPort
in interface ServletRequest
public String getMethod()
getMethod
in interface HttpServletRequest
public String getParameter(String name)
getParameter
in interface ServletRequest
public Map<String,String[]> getParameterMap()
getParameterMap
in interface ServletRequest
public Enumeration<String> getParameterNames()
getParameterNames
in interface ServletRequest
public String[] getParameterValues(String name)
getParameterValues
in interface ServletRequest
public void resetParameters()
public String getPathInfo()
getPathInfo
in interface HttpServletRequest
public String getPathTranslated()
getPathTranslated
in interface HttpServletRequest
public String getProtocol()
getProtocol
in interface ServletRequest
public HttpVersion getHttpVersion()
public String getQueryEncoding()
public String getQueryString()
getQueryString
in interface HttpServletRequest
public BufferedReader getReader() throws IOException
getReader
in interface ServletRequest
IOException
public String getRealPath(String path)
getRealPath
in interface ServletRequest
public InetSocketAddress getRemoteInetSocketAddress()
InetSocketAddress
for this request.InetSocketAddress
for this request, or null if the request has no remote (see ServletRequest.getRemoteAddr()
for
conditions that result in no remote address)public String getRemoteAddr()
getRemoteAddr
in interface ServletRequest
public String getRemoteHost()
getRemoteHost
in interface ServletRequest
public int getRemotePort()
getRemotePort
in interface ServletRequest
public String getRemoteUser()
getRemoteUser
in interface HttpServletRequest
public RequestDispatcher getRequestDispatcher(String path)
getRequestDispatcher
in interface ServletRequest
public String getRequestedSessionId()
getRequestedSessionId
in interface HttpServletRequest
public String getRequestURI()
getRequestURI
in interface HttpServletRequest
public StringBuffer getRequestURL()
getRequestURL
in interface HttpServletRequest
public Response getResponse()
public StringBuilder getRootURL()
Because this method returns a StringBuffer
, not a string, you can modify the URL easily, for example, to append path and query parameters.
This method is useful for creating redirect messages and for reporting errors.
public String getScheme()
getScheme
in interface ServletRequest
public String getServerName()
getServerName
in interface ServletRequest
public int getServerPort()
getServerPort
in interface ServletRequest
public ServletContext getServletContext()
getServletContext
in interface ServletRequest
public String getServletName()
public String getServletPath()
getServletPath
in interface HttpServletRequest
public ServletResponse getServletResponse()
public String changeSessionId()
changeSessionId
in interface HttpServletRequest
public HttpSession getSession()
getSession
in interface HttpServletRequest
public HttpSession getSession(boolean create)
getSession
in interface HttpServletRequest
public SessionManager getSessionManager()
public long getTimeStamp()
public HttpURI getUri()
public UserIdentity getUserIdentity()
public UserIdentity getResolvedUserIdentity()
Authentication
is not Authentication.User
(eg.
Authentication.Deferred
).public UserIdentity.Scope getUserIdentityScope()
public Principal getUserPrincipal()
getUserPrincipal
in interface HttpServletRequest
public boolean isHandled()
public boolean isAsyncStarted()
isAsyncStarted
in interface ServletRequest
public boolean isAsyncSupported()
isAsyncSupported
in interface ServletRequest
public boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie
in interface HttpServletRequest
public boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl
in interface HttpServletRequest
public boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL
in interface HttpServletRequest
public boolean isRequestedSessionIdValid()
isRequestedSessionIdValid
in interface HttpServletRequest
public boolean isSecure()
isSecure
in interface ServletRequest
public void setSecure(boolean secure)
public boolean isUserInRole(String role)
isUserInRole
in interface HttpServletRequest
public HttpSession recoverNewSession(Object key)
protected void recycle()
public void removeAttribute(String name)
removeAttribute
in interface ServletRequest
public void removeEventListener(EventListener listener)
public void saveNewSession(Object key, HttpSession session)
public void setAsyncSupported(boolean supported)
public void setAttribute(String name, Object value)
setAttribute
in interface ServletRequest
public void setAttributes(Attributes attributes)
public void setAuthentication(Authentication authentication)
authentication
- the authentication to setpublic void setCharacterEncoding(String encoding) throws UnsupportedEncodingException
setCharacterEncoding
in interface ServletRequest
UnsupportedEncodingException
public void setCharacterEncodingUnchecked(String encoding)
public void setContentType(String contentType)
public void setContext(ContextHandler.Context context)
context
- context objectpublic boolean takeNewContext()
takeNewContext()
since the last
setContext(org.eclipse.jetty.server.handler.ContextHandler.Context)
call.public void setContextPath(String contextPath)
HttpServletRequest.getContextPath()
public void setCookies(Cookie[] cookies)
cookies
- The cookies to set.public void setDispatcherType(DispatcherType type)
public void setHandled(boolean h)
public void setMethod(HttpMethod httpMethod, String method)
method
- The method to set.public boolean isHead()
public void setPathInfo(String pathInfo)
pathInfo
- The pathInfo to set.public void setHttpVersion(HttpVersion version)
version
- The protocol to set.public void setQueryEncoding(String queryEncoding)
queryEncoding
- public void setQueryString(String queryString)
queryString
- The queryString to set.public void setRemoteAddr(InetSocketAddress addr)
addr
- The address to set.public void setRequestedSessionId(String requestedSessionId)
requestedSessionId
- The requestedSessionId to set.public void setRequestedSessionIdFromCookie(boolean requestedSessionIdCookie)
requestedSessionIdCookie
- The requestedSessionIdCookie to set.public void setRequestURI(String requestURI)
requestURI
- The requestURI to set.public void setScheme(String scheme)
scheme
- The scheme to set.public void setServerName(String host)
host
- The host to set.public void setServerPort(int port)
port
- The port to set.public void setServletPath(String servletPath)
servletPath
- The servletPath to set.public void setSession(HttpSession session)
session
- The session to set.public void setSessionManager(SessionManager sessionManager)
sessionManager
- The sessionManager to set.public void setTimeStamp(long ts)
public void setUri(HttpURI uri)
uri
- The uri to set.public void setUserIdentityScope(UserIdentity.Scope scope)
public AsyncContext startAsync() throws IllegalStateException
startAsync
in interface ServletRequest
IllegalStateException
public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException
startAsync
in interface ServletRequest
IllegalStateException
public boolean authenticate(HttpServletResponse response) throws IOException, ServletException
authenticate
in interface HttpServletRequest
IOException
ServletException
public Part getPart(String name) throws IOException, ServletException
getPart
in interface HttpServletRequest
IOException
ServletException
public Collection<Part> getParts() throws IOException, ServletException
getParts
in interface HttpServletRequest
IOException
ServletException
public void login(String username, String password) throws ServletException
login
in interface HttpServletRequest
ServletException
public void logout() throws ServletException
logout
in interface HttpServletRequest
ServletException
public void mergeQueryParameters(String newQuery, boolean updateQueryString)
public <T extends HttpUpgradeHandler> T upgrade(Class<T> handlerClass) throws IOException, ServletException
upgrade
in interface HttpServletRequest
IOException
ServletException
HttpServletRequest.upgrade(java.lang.Class)
Copyright © 1995-2015 Webtide. All Rights Reserved.