public class Request
extends java.lang.Object
implements javax.servlet.http.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.AbstractHttpConnection accepted by the server and recycled for each HTTP request received via that connection.
An effort is made to avoid reparsing headers and cookies that are likely to be the same for requests from the same connection.
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 | Field and Description |
|---|---|
protected AsyncContinuation |
_async |
protected AbstractHttpConnection |
_connection |
| Constructor and Description |
|---|
Request() |
Request(AbstractHttpConnection connection) |
| Modifier and Type | Method and Description |
|---|---|
void |
addEventListener(java.util.EventListener listener) |
void |
extractParameters()
Extract Parameters from query string and/or form _content.
|
AsyncContext |
getAsyncContext() |
AsyncContinuation |
getAsyncContinuation() |
java.lang.Object |
getAttribute(java.lang.String name) |
java.util.Enumeration |
getAttributeNames() |
Attributes |
getAttributes() |
Authentication |
getAuthentication()
Get the authentication.
|
java.lang.String |
getAuthType() |
java.lang.String |
getCharacterEncoding() |
AbstractHttpConnection |
getConnection() |
int |
getContentLength() |
long |
getContentRead() |
java.lang.String |
getContentType() |
ContextHandler.Context |
getContext() |
java.lang.String |
getContextPath() |
javax.servlet.http.Cookie[] |
getCookies() |
long |
getDateHeader(java.lang.String name) |
DispatcherType |
getDispatcherType() |
long |
getDispatchTime()
Get timestamp of the request dispatch
|
java.lang.String |
getHeader(java.lang.String name) |
java.util.Enumeration |
getHeaderNames() |
java.util.Enumeration |
getHeaders(java.lang.String name) |
int |
getInputState() |
javax.servlet.ServletInputStream |
getInputStream() |
int |
getIntHeader(java.lang.String name) |
java.lang.String |
getLocalAddr() |
java.util.Locale |
getLocale() |
java.util.Enumeration |
getLocales() |
java.lang.String |
getLocalName() |
int |
getLocalPort() |
java.lang.String |
getMethod() |
java.lang.String |
getParameter(java.lang.String name) |
java.util.Map |
getParameterMap() |
java.util.Enumeration |
getParameterNames() |
MultiMap<java.lang.String> |
getParameters() |
java.lang.String[] |
getParameterValues(java.lang.String name) |
java.lang.String |
getPathInfo() |
java.lang.String |
getPathTranslated() |
java.lang.String |
getProtocol() |
java.lang.String |
getQueryEncoding() |
java.lang.String |
getQueryString() |
java.io.BufferedReader |
getReader() |
java.lang.String |
getRealPath(java.lang.String path) |
java.lang.String |
getRemoteAddr() |
java.lang.String |
getRemoteHost() |
int |
getRemotePort() |
java.lang.String |
getRemoteUser() |
static Request |
getRequest(javax.servlet.http.HttpServletRequest request) |
javax.servlet.RequestDispatcher |
getRequestDispatcher(java.lang.String path) |
java.lang.String |
getRequestedSessionId() |
java.lang.String |
getRequestURI() |
java.lang.StringBuffer |
getRequestURL() |
UserIdentity |
getResolvedUserIdentity() |
Response |
getResponse() |
java.lang.StringBuilder |
getRootURL()
Reconstructs the URL the client used to make the request.
|
java.lang.String |
getScheme() |
java.lang.String |
getServerName() |
int |
getServerPort() |
javax.servlet.ServletContext |
getServletContext() |
java.lang.String |
getServletName() |
java.lang.String |
getServletPath() |
javax.servlet.ServletResponse |
getServletResponse() |
javax.servlet.http.HttpSession |
getSession() |
javax.servlet.http.HttpSession |
getSession(boolean create) |
SessionManager |
getSessionManager() |
long |
getTimeStamp()
Get Request TimeStamp
|
Buffer |
getTimeStampBuffer()
Get Request TimeStamp
|
HttpURI |
getUri() |
UserIdentity |
getUserIdentity() |
UserIdentity.Scope |
getUserIdentityScope() |
java.security.Principal |
getUserPrincipal() |
boolean |
isAsyncSupported() |
boolean |
isHandled() |
boolean |
isRequestedSessionIdFromCookie() |
boolean |
isRequestedSessionIdFromUrl() |
boolean |
isRequestedSessionIdFromURL() |
boolean |
isRequestedSessionIdValid() |
boolean |
isSecure() |
boolean |
isUserInRole(java.lang.String role) |
void |
mergeQueryString(java.lang.String query)
Merge in a new query string.
|
javax.servlet.http.HttpSession |
recoverNewSession(java.lang.Object key) |
protected void |
recycle() |
void |
removeAttribute(java.lang.String name) |
void |
removeEventListener(java.util.EventListener listener) |
void |
saveNewSession(java.lang.Object key,
javax.servlet.http.HttpSession session) |
void |
setAsyncSupported(boolean supported) |
void |
setAttribute(java.lang.String name,
java.lang.Object value) |
void |
setAttributes(Attributes attributes) |
void |
setAuthentication(Authentication authentication)
Set the authentication.
|
void |
setCharacterEncoding(java.lang.String encoding) |
void |
setCharacterEncodingUnchecked(java.lang.String encoding) |
protected void |
setConnection(AbstractHttpConnection connection) |
void |
setContentType(java.lang.String contentType) |
void |
setContext(ContextHandler.Context context)
Set request context
|
void |
setContextPath(java.lang.String contextPath)
Sets the "context path" for this request
|
void |
setCookies(javax.servlet.http.Cookie[] cookies) |
void |
setDispatcherType(DispatcherType type) |
void |
setDispatchTime(long value)
Set timetstamp of request dispatch
|
void |
setHandled(boolean h) |
void |
setMethod(java.lang.String method) |
void |
setParameters(MultiMap<java.lang.String> parameters) |
void |
setPathInfo(java.lang.String pathInfo) |
void |
setProtocol(java.lang.String protocol) |
void |
setQueryEncoding(java.lang.String queryEncoding)
Set the character encoding used for the query string.
|
void |
setQueryString(java.lang.String queryString) |
void |
setRemoteAddr(java.lang.String addr) |
void |
setRemoteHost(java.lang.String host) |
void |
setRequestedSessionId(java.lang.String requestedSessionId) |
void |
setRequestedSessionIdFromCookie(boolean requestedSessionIdCookie) |
void |
setRequestURI(java.lang.String requestURI) |
void |
setScheme(java.lang.String scheme) |
void |
setServerName(java.lang.String host) |
void |
setServerPort(int port) |
void |
setServletPath(java.lang.String servletPath) |
void |
setSession(javax.servlet.http.HttpSession session) |
void |
setSessionManager(SessionManager sessionManager) |
void |
setTimeStamp(long ts) |
void |
setUri(HttpURI uri) |
void |
setUserIdentityScope(UserIdentity.Scope scope) |
AsyncContext |
startAsync() |
AsyncContext |
startAsync(javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse) |
boolean |
takeNewContext() |
java.lang.String |
toString() |
protected final AsyncContinuation _async
protected AbstractHttpConnection _connection
public Request()
public Request(AbstractHttpConnection connection)
public static Request getRequest(javax.servlet.http.HttpServletRequest request)
public void addEventListener(java.util.EventListener listener)
public void extractParameters()
public AsyncContext getAsyncContext()
public AsyncContinuation getAsyncContinuation()
public java.lang.Object getAttribute(java.lang.String name)
getAttribute in interface javax.servlet.ServletRequestpublic java.util.Enumeration getAttributeNames()
getAttributeNames in interface javax.servlet.ServletRequestpublic Attributes getAttributes()
public Authentication getAuthentication()
public java.lang.String getAuthType()
getAuthType in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getCharacterEncoding()
getCharacterEncoding in interface javax.servlet.ServletRequestpublic AbstractHttpConnection getConnection()
public int getContentLength()
getContentLength in interface javax.servlet.ServletRequestpublic long getContentRead()
public java.lang.String getContentType()
getContentType in interface javax.servlet.ServletRequestpublic 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 java.lang.String getContextPath()
getContextPath in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.http.Cookie[] getCookies()
getCookies in interface javax.servlet.http.HttpServletRequestpublic long getDateHeader(java.lang.String name)
getDateHeader in interface javax.servlet.http.HttpServletRequestpublic DispatcherType getDispatcherType()
public java.lang.String getHeader(java.lang.String name)
getHeader in interface javax.servlet.http.HttpServletRequestpublic java.util.Enumeration getHeaderNames()
getHeaderNames in interface javax.servlet.http.HttpServletRequestpublic java.util.Enumeration getHeaders(java.lang.String name)
getHeaders in interface javax.servlet.http.HttpServletRequestpublic int getInputState()
public javax.servlet.ServletInputStream getInputStream()
throws java.io.IOException
getInputStream in interface javax.servlet.ServletRequestjava.io.IOExceptionpublic int getIntHeader(java.lang.String name)
getIntHeader in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getLocalAddr()
getLocalAddr in interface javax.servlet.ServletRequestpublic java.util.Locale getLocale()
getLocale in interface javax.servlet.ServletRequestpublic java.util.Enumeration getLocales()
getLocales in interface javax.servlet.ServletRequestpublic java.lang.String getLocalName()
getLocalName in interface javax.servlet.ServletRequestpublic int getLocalPort()
getLocalPort in interface javax.servlet.ServletRequestpublic java.lang.String getMethod()
getMethod in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getParameter(java.lang.String name)
getParameter in interface javax.servlet.ServletRequestpublic java.util.Map getParameterMap()
getParameterMap in interface javax.servlet.ServletRequestpublic java.util.Enumeration getParameterNames()
getParameterNames in interface javax.servlet.ServletRequestpublic MultiMap<java.lang.String> getParameters()
public java.lang.String[] getParameterValues(java.lang.String name)
getParameterValues in interface javax.servlet.ServletRequestpublic java.lang.String getPathInfo()
getPathInfo in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getPathTranslated()
getPathTranslated in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getProtocol()
getProtocol in interface javax.servlet.ServletRequestpublic java.lang.String getQueryEncoding()
public java.lang.String getQueryString()
getQueryString in interface javax.servlet.http.HttpServletRequestpublic java.io.BufferedReader getReader()
throws java.io.IOException
getReader in interface javax.servlet.ServletRequestjava.io.IOExceptionpublic java.lang.String getRealPath(java.lang.String path)
getRealPath in interface javax.servlet.ServletRequestpublic java.lang.String getRemoteAddr()
getRemoteAddr in interface javax.servlet.ServletRequestpublic java.lang.String getRemoteHost()
getRemoteHost in interface javax.servlet.ServletRequestpublic int getRemotePort()
getRemotePort in interface javax.servlet.ServletRequestpublic java.lang.String getRemoteUser()
getRemoteUser in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)
getRequestDispatcher in interface javax.servlet.ServletRequestpublic java.lang.String getRequestedSessionId()
getRequestedSessionId in interface javax.servlet.http.HttpServletRequestpublic java.lang.String getRequestURI()
getRequestURI in interface javax.servlet.http.HttpServletRequestpublic java.lang.StringBuffer getRequestURL()
getRequestURL in interface javax.servlet.http.HttpServletRequestpublic Response getResponse()
public java.lang.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 java.lang.String getScheme()
getScheme in interface javax.servlet.ServletRequestpublic java.lang.String getServerName()
getServerName in interface javax.servlet.ServletRequestpublic int getServerPort()
getServerPort in interface javax.servlet.ServletRequestpublic javax.servlet.ServletContext getServletContext()
public java.lang.String getServletName()
public java.lang.String getServletPath()
getServletPath in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.ServletResponse getServletResponse()
public javax.servlet.http.HttpSession getSession()
getSession in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.http.HttpSession getSession(boolean create)
getSession in interface javax.servlet.http.HttpServletRequestpublic SessionManager getSessionManager()
public long getTimeStamp()
public Buffer getTimeStampBuffer()
public HttpURI getUri()
public UserIdentity getUserIdentity()
public UserIdentity getResolvedUserIdentity()
Authentication is not Authentication.User (eg.
Authentication.Deferred).public UserIdentity.Scope getUserIdentityScope()
public java.security.Principal getUserPrincipal()
getUserPrincipal in interface javax.servlet.http.HttpServletRequestpublic long getDispatchTime()
public boolean isHandled()
public boolean isAsyncSupported()
public boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie in interface javax.servlet.http.HttpServletRequestpublic boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl in interface javax.servlet.http.HttpServletRequestpublic boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL in interface javax.servlet.http.HttpServletRequestpublic boolean isRequestedSessionIdValid()
isRequestedSessionIdValid in interface javax.servlet.http.HttpServletRequestpublic boolean isSecure()
isSecure in interface javax.servlet.ServletRequestpublic boolean isUserInRole(java.lang.String role)
isUserInRole in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.http.HttpSession recoverNewSession(java.lang.Object key)
protected void recycle()
public void removeAttribute(java.lang.String name)
removeAttribute in interface javax.servlet.ServletRequestpublic void removeEventListener(java.util.EventListener listener)
public void saveNewSession(java.lang.Object key,
javax.servlet.http.HttpSession session)
public void setAsyncSupported(boolean supported)
public void setAttribute(java.lang.String name,
java.lang.Object value)
setAttribute in interface javax.servlet.ServletRequestpublic void setAttributes(Attributes attributes)
public void setAuthentication(Authentication authentication)
authentication - the authentication to setpublic void setCharacterEncoding(java.lang.String encoding)
throws java.io.UnsupportedEncodingException
setCharacterEncoding in interface javax.servlet.ServletRequestjava.io.UnsupportedEncodingExceptionpublic void setCharacterEncodingUnchecked(java.lang.String encoding)
protected final void setConnection(AbstractHttpConnection connection)
public void setContentType(java.lang.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(java.lang.String contextPath)
HttpServletRequest.getContextPath()public void setCookies(javax.servlet.http.Cookie[] cookies)
cookies - The cookies to set.public void setDispatcherType(DispatcherType type)
public void setHandled(boolean h)
public void setMethod(java.lang.String method)
method - The method to set.public void setParameters(MultiMap<java.lang.String> parameters)
parameters - The parameters to set.public void setPathInfo(java.lang.String pathInfo)
pathInfo - The pathInfo to set.public void setProtocol(java.lang.String protocol)
protocol - The protocol to set.public void setQueryEncoding(java.lang.String queryEncoding)
queryEncoding - public void setQueryString(java.lang.String queryString)
queryString - The queryString to set.public void setRemoteAddr(java.lang.String addr)
addr - The address to set.public void setRemoteHost(java.lang.String host)
host - The host to set.public void setRequestedSessionId(java.lang.String requestedSessionId)
requestedSessionId - The requestedSessionId to set.public void setRequestedSessionIdFromCookie(boolean requestedSessionIdCookie)
requestedSessionIdCookie - The requestedSessionIdCookie to set.public void setRequestURI(java.lang.String requestURI)
requestURI - The requestURI to set.public void setScheme(java.lang.String scheme)
scheme - The scheme to set.public void setServerName(java.lang.String host)
host - The host to set.public void setServerPort(int port)
port - The port to set.public void setServletPath(java.lang.String servletPath)
servletPath - The servletPath to set.public void setSession(javax.servlet.http.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 void setDispatchTime(long value)
value - timestamppublic AsyncContext startAsync() throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionpublic AsyncContext startAsync(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse) throws java.lang.IllegalStateException
java.lang.IllegalStateExceptionpublic java.lang.String toString()
toString in class java.lang.Objectpublic void mergeQueryString(java.lang.String query)
setParameters(MultiMap) and
setQueryString(String) are called with the result. The merge is according to the rules of the servlet dispatch forward method.query - The query string to merge into the request.Copyright © 2013 FuseSource, Corp.. All Rights Reserved.