HttpServletRequest, ServletRequestpublic class Request extends java.lang.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.A request instance is created for each connection 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.
Request instances are recycled, which combined with badly written asynchronous applications can result in calls on requests that have been reset. The code is written in a style to avoid NPE and ISE when such calls are made, as this has often proved generate exceptions that distraction from debugging such bad asynchronous applications. Instead, request methods attempt to not fail when called in an illegal state, so that hopefully the bad application will proceed to a major state event (eg calling AsyncContext.onComplete) which has better asynchronous guards, true atomic state and better failure behaviour that will assist in debugging.
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.
If IOExceptions or timeouts occur while reading form parameters, these are thrown as unchecked Exceptions: ether RuntimeIOException,
BadMessageException or RuntimeException as appropriate.
| Modifier and Type | Field | Description |
|---|---|---|
static java.lang.String |
__MULTIPART_CONFIG_ELEMENT |
|
static java.lang.String |
__MULTIPARTS |
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH| Constructor | Description |
|---|---|
Request(HttpChannel channel,
HttpInput input) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
addEventListener(java.util.EventListener listener) |
|
boolean |
authenticate(HttpServletResponse response) |
|
java.lang.String |
changeSessionId() |
|
void |
extractFormParameters(org.eclipse.jetty.util.MultiMap<java.lang.String> params) |
|
AsyncContext |
getAsyncContext() |
|
java.lang.Object |
getAttribute(java.lang.String name) |
Get Request Attribute.
|
java.util.Enumeration<java.lang.String> |
getAttributeNames() |
|
org.eclipse.jetty.util.Attributes |
getAttributes() |
|
Authentication |
getAuthentication() |
Get the authentication.
|
java.lang.String |
getAuthType() |
|
static Request |
getBaseRequest(ServletRequest request) |
Obtain the base
Request instance of a ServletRequest, by
coercion, unwrapping or special attribute. |
java.lang.String |
getCharacterEncoding() |
|
int |
getContentLength() |
|
long |
getContentLengthLong() |
|
long |
getContentRead() |
|
java.lang.String |
getContentType() |
|
ContextHandler.Context |
getContext() |
|
java.lang.String |
getContextPath() |
|
Cookie[] |
getCookies() |
|
long |
getDateHeader(java.lang.String name) |
|
DispatcherType |
getDispatcherType() |
|
java.lang.String |
getHeader(java.lang.String name) |
|
java.util.Enumeration<java.lang.String> |
getHeaderNames() |
|
java.util.Enumeration<java.lang.String> |
getHeaders(java.lang.String name) |
|
HttpChannel |
getHttpChannel() |
|
HttpChannelState |
getHttpChannelState() |
|
org.eclipse.jetty.http.HttpFields |
getHttpFields() |
|
HttpInput |
getHttpInput() |
|
org.eclipse.jetty.http.HttpURI |
getHttpURI() |
|
org.eclipse.jetty.http.HttpVersion |
getHttpVersion() |
|
int |
getInputState() |
|
ServletInputStream |
getInputStream() |
|
int |
getIntHeader(java.lang.String name) |
|
java.lang.String |
getLocalAddr() |
|
java.util.Locale |
getLocale() |
|
java.util.Enumeration<java.util.Locale> |
getLocales() |
|
java.lang.String |
getLocalName() |
|
int |
getLocalPort() |
|
org.eclipse.jetty.http.MetaData.Request |
getMetaData() |
|
java.lang.String |
getMethod() |
|
java.lang.String |
getOriginalURI() |
|
java.lang.String |
getParameter(java.lang.String name) |
|
java.util.Map<java.lang.String,java.lang.String[]> |
getParameterMap() |
|
java.util.Enumeration<java.lang.String> |
getParameterNames() |
|
java.lang.String[] |
getParameterValues(java.lang.String name) |
|
Part |
getPart(java.lang.String name) |
|
java.util.Collection<Part> |
getParts() |
|
java.lang.String |
getPathInfo() |
|
java.lang.String |
getPathTranslated() |
|
java.lang.String |
getProtocol() |
|
PushBuilder |
getPushBuilder() |
Get a PushBuilder associated with this request initialized as follows:
The method is initialized to "GET"
The headers from this request are copied to the Builder, except for:
Conditional headers (eg.
|
java.lang.String |
getQueryEncoding() |
|
org.eclipse.jetty.util.MultiMap<java.lang.String> |
getQueryParameters() |
|
java.lang.String |
getQueryString() |
|
java.io.BufferedReader |
getReader() |
|
java.lang.String |
getRealPath(java.lang.String path) |
|
java.lang.String |
getRemoteAddr() |
|
java.lang.String |
getRemoteHost() |
|
java.net.InetSocketAddress |
getRemoteInetSocketAddress() |
Access the underlying Remote
InetSocketAddress for this request. |
int |
getRemotePort() |
|
java.lang.String |
getRemoteUser() |
|
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() |
|
ServletContext |
getServletContext() |
|
java.lang.String |
getServletName() |
|
java.lang.String |
getServletPath() |
|
ServletResponse |
getServletResponse() |
|
HttpSession |
getSession() |
|
HttpSession |
getSession(boolean create) |
|
SessionHandler |
getSessionHandler() |
|
long |
getTimeStamp() |
Get Request TimeStamp
|
org.eclipse.jetty.http.HttpFields |
getTrailers() |
|
UserIdentity |
getUserIdentity() |
|
UserIdentity.Scope |
getUserIdentityScope() |
|
java.security.Principal |
getUserPrincipal() |
|
boolean |
hasMetaData() |
|
boolean |
isAsyncStarted() |
|
boolean |
isAsyncSupported() |
|
boolean |
isHandled() |
|
boolean |
isHead() |
|
boolean |
isPush() |
|
boolean |
isPushSupported() |
|
boolean |
isRequestedSessionIdFromCookie() |
|
boolean |
isRequestedSessionIdFromUrl() |
|
boolean |
isRequestedSessionIdFromURL() |
|
boolean |
isRequestedSessionIdValid() |
|
boolean |
isSecure() |
|
boolean |
isUserInRole(java.lang.String role) |
|
void |
login(java.lang.String username,
java.lang.String password) |
|
void |
logout() |
|
void |
mergeQueryParameters(java.lang.String oldQuery,
java.lang.String newQuery,
boolean updateQueryString) |
|
protected void |
recycle() |
|
void |
removeAttribute(java.lang.String name) |
|
void |
removeEventListener(java.util.EventListener listener) |
|
void |
resetParameters() |
|
void |
setAsyncSupported(boolean supported,
java.lang.String source) |
|
void |
setAttribute(java.lang.String name,
java.lang.Object value) |
|
void |
setAttributes(org.eclipse.jetty.util.Attributes attributes) |
|
void |
setAuthentication(Authentication authentication) |
Set the authentication.
|
void |
setAuthority(java.lang.String host,
int port) |
|
void |
setCharacterEncoding(java.lang.String encoding) |
|
void |
setCharacterEncodingUnchecked(java.lang.String encoding) |
|
void |
setContentParameters(org.eclipse.jetty.util.MultiMap<java.lang.String> contentParameters) |
|
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(Cookie[] cookies) |
|
void |
setDispatcherType(DispatcherType type) |
|
void |
setHandled(boolean h) |
|
void |
setHttpURI(org.eclipse.jetty.http.HttpURI uri) |
|
void |
setHttpVersion(org.eclipse.jetty.http.HttpVersion version) |
|
void |
setMetaData(org.eclipse.jetty.http.MetaData.Request request) |
|
void |
setMethod(java.lang.String method) |
|
void |
setPathInfo(java.lang.String pathInfo) |
|
void |
setQueryEncoding(java.lang.String queryEncoding) |
Set the character encoding used for the query string.
|
void |
setQueryParameters(org.eclipse.jetty.util.MultiMap<java.lang.String> queryParameters) |
|
void |
setQueryString(java.lang.String queryString) |
|
void |
setRemoteAddr(java.net.InetSocketAddress addr) |
|
void |
setRequestedSessionId(java.lang.String requestedSessionId) |
|
void |
setRequestedSessionIdFromCookie(boolean requestedSessionIdCookie) |
|
void |
setScheme(java.lang.String scheme) |
|
void |
setSecure(boolean secure) |
|
void |
setServletPath(java.lang.String servletPath) |
|
void |
setSession(HttpSession session) |
|
void |
setSessionHandler(SessionHandler sessionHandler) |
|
void |
setTimeStamp(long ts) |
|
void |
setURIPathQuery(java.lang.String requestURI) |
|
void |
setUserIdentityScope(UserIdentity.Scope scope) |
|
AsyncContext |
startAsync() |
|
AsyncContext |
startAsync(ServletRequest servletRequest,
ServletResponse servletResponse) |
|
boolean |
takeNewContext() |
|
java.lang.String |
toString() |
|
<T extends HttpUpgradeHandler> |
upgrade(java.lang.Class<T> handlerClass) |
public static final java.lang.String __MULTIPART_CONFIG_ELEMENT
public static final java.lang.String __MULTIPARTS
public Request(HttpChannel channel, HttpInput input)
public static Request getBaseRequest(ServletRequest request)
Request instance of a ServletRequest, by
coercion, unwrapping or special attribute.request - The requestRequest instance of a ServletRequest.public org.eclipse.jetty.http.HttpFields getHttpFields()
public org.eclipse.jetty.http.HttpFields getTrailers()
public HttpInput getHttpInput()
public boolean isPush()
public boolean isPushSupported()
public PushBuilder getPushBuilder()
getQueryString()
getRequestedSessionId() value, unless at the time
of the call getSession(boolean)
has previously been called to create a new HttpSession, in
which case the new session ID will be used as the PushBuilders
requested session ID.getRequestURL()
plus any getQueryString() HttpServletResponse.addCookie(Cookie) has been called
on the associated response, then a corresponding Cookie header will be added
to the PushBuilder, unless the Cookie.getMaxAge() is <=0, in which
case the Cookie will be removed from the builder.PushBuilderImpl.isConditional() header is set
to true.
Each call to getPushBuilder() will return a new instance of a PushBuilder based off this Request. Any mutations to the returned PushBuilder are not reflected on future returns.
public void addEventListener(java.util.EventListener listener)
public void extractFormParameters(org.eclipse.jetty.util.MultiMap<java.lang.String> params)
public AsyncContext getAsyncContext()
getAsyncContext in interface ServletRequestpublic HttpChannelState getHttpChannelState()
public java.lang.Object getAttribute(java.lang.String name)
Also supports jetty specific attributes to gain access to Jetty APIs:
getAttribute in interface ServletRequestServletRequest.getAttribute(java.lang.String)public java.util.Enumeration<java.lang.String> getAttributeNames()
getAttributeNames in interface ServletRequestpublic org.eclipse.jetty.util.Attributes getAttributes()
public Authentication getAuthentication()
public java.lang.String getAuthType()
getAuthType in interface HttpServletRequestpublic java.lang.String getCharacterEncoding()
getCharacterEncoding in interface ServletRequestpublic HttpChannel getHttpChannel()
public int getContentLength()
getContentLength in interface ServletRequestpublic long getContentLengthLong()
getContentLengthLong in interface ServletRequestpublic long getContentRead()
public java.lang.String getContentType()
getContentType in interface 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 HttpServletRequestpublic Cookie[] getCookies()
getCookies in interface HttpServletRequestpublic long getDateHeader(java.lang.String name)
getDateHeader in interface HttpServletRequestpublic DispatcherType getDispatcherType()
getDispatcherType in interface ServletRequestpublic java.lang.String getHeader(java.lang.String name)
getHeader in interface HttpServletRequestpublic java.util.Enumeration<java.lang.String> getHeaderNames()
getHeaderNames in interface HttpServletRequestpublic java.util.Enumeration<java.lang.String> getHeaders(java.lang.String name)
getHeaders in interface HttpServletRequestpublic int getInputState()
public ServletInputStream getInputStream() throws java.io.IOException
getInputStream in interface ServletRequestjava.io.IOExceptionpublic int getIntHeader(java.lang.String name)
getIntHeader in interface HttpServletRequestpublic java.util.Locale getLocale()
getLocale in interface ServletRequestpublic java.util.Enumeration<java.util.Locale> getLocales()
getLocales in interface ServletRequestpublic java.lang.String getLocalAddr()
getLocalAddr in interface ServletRequestpublic java.lang.String getLocalName()
getLocalName in interface ServletRequestpublic int getLocalPort()
getLocalPort in interface ServletRequestpublic java.lang.String getMethod()
getMethod in interface HttpServletRequestpublic java.lang.String getParameter(java.lang.String name)
getParameter in interface ServletRequestpublic java.util.Map<java.lang.String,java.lang.String[]> getParameterMap()
getParameterMap in interface ServletRequestpublic java.util.Enumeration<java.lang.String> getParameterNames()
getParameterNames in interface ServletRequestpublic java.lang.String[] getParameterValues(java.lang.String name)
getParameterValues in interface ServletRequestpublic org.eclipse.jetty.util.MultiMap<java.lang.String> getQueryParameters()
public void setQueryParameters(org.eclipse.jetty.util.MultiMap<java.lang.String> queryParameters)
public void setContentParameters(org.eclipse.jetty.util.MultiMap<java.lang.String> contentParameters)
public void resetParameters()
public java.lang.String getPathInfo()
getPathInfo in interface HttpServletRequestpublic java.lang.String getPathTranslated()
getPathTranslated in interface HttpServletRequestpublic java.lang.String getProtocol()
getProtocol in interface ServletRequestpublic org.eclipse.jetty.http.HttpVersion getHttpVersion()
public java.lang.String getQueryEncoding()
public java.lang.String getQueryString()
getQueryString in interface HttpServletRequestpublic java.io.BufferedReader getReader()
throws java.io.IOException
getReader in interface ServletRequestjava.io.IOExceptionpublic java.lang.String getRealPath(java.lang.String path)
getRealPath in interface ServletRequestpublic java.net.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 java.lang.String getRemoteAddr()
getRemoteAddr in interface ServletRequestpublic java.lang.String getRemoteHost()
getRemoteHost in interface ServletRequestpublic int getRemotePort()
getRemotePort in interface ServletRequestpublic java.lang.String getRemoteUser()
getRemoteUser in interface HttpServletRequestpublic RequestDispatcher getRequestDispatcher(java.lang.String path)
getRequestDispatcher in interface ServletRequestpublic java.lang.String getRequestedSessionId()
getRequestedSessionId in interface HttpServletRequestpublic java.lang.String getRequestURI()
getRequestURI in interface HttpServletRequestpublic java.lang.StringBuffer getRequestURL()
getRequestURL in interface 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 ServletRequestpublic java.lang.String getServerName()
getServerName in interface ServletRequestpublic int getServerPort()
getServerPort in interface ServletRequestpublic ServletContext getServletContext()
getServletContext in interface ServletRequestpublic java.lang.String getServletName()
public java.lang.String getServletPath()
getServletPath in interface HttpServletRequestpublic ServletResponse getServletResponse()
public java.lang.String changeSessionId()
changeSessionId in interface HttpServletRequestpublic HttpSession getSession()
getSession in interface HttpServletRequestpublic HttpSession getSession(boolean create)
getSession in interface HttpServletRequestpublic SessionHandler getSessionHandler()
public long getTimeStamp()
public org.eclipse.jetty.http.HttpURI getHttpURI()
public java.lang.String getOriginalURI()
public void setHttpURI(org.eclipse.jetty.http.HttpURI uri)
uri - the URI to setpublic 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 HttpServletRequestpublic boolean isHandled()
public boolean isAsyncStarted()
isAsyncStarted in interface ServletRequestpublic boolean isAsyncSupported()
isAsyncSupported in interface ServletRequestpublic 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 void setSecure(boolean secure)
public boolean isUserInRole(java.lang.String role)
isUserInRole in interface HttpServletRequestpublic void setMetaData(org.eclipse.jetty.http.MetaData.Request request)
request - the Request metadatapublic org.eclipse.jetty.http.MetaData.Request getMetaData()
public boolean hasMetaData()
protected void recycle()
public void removeAttribute(java.lang.String name)
removeAttribute in interface ServletRequestpublic void removeEventListener(java.util.EventListener listener)
public void setAsyncSupported(boolean supported,
java.lang.String source)
public void setAttribute(java.lang.String name,
java.lang.Object value)
setAttribute in interface ServletRequestpublic void setAttributes(org.eclipse.jetty.util.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 ServletRequestjava.io.UnsupportedEncodingExceptionpublic void setCharacterEncodingUnchecked(java.lang.String encoding)
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)
contextPath - the context path for this requestHttpServletRequest.getContextPath()public void setCookies(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 setHttpVersion(org.eclipse.jetty.http.HttpVersion version)
public boolean isHead()
public void setPathInfo(java.lang.String pathInfo)
pathInfo - The pathInfo to set.public void setQueryEncoding(java.lang.String queryEncoding)
queryEncoding - the URI query character encodingpublic void setQueryString(java.lang.String queryString)
queryString - The queryString to set.public void setRemoteAddr(java.net.InetSocketAddress addr)
addr - The address 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 setURIPathQuery(java.lang.String requestURI)
public void setScheme(java.lang.String scheme)
scheme - The scheme to set.public void setAuthority(java.lang.String host,
int port)
host - The host to set.port - the port to setpublic void setServletPath(java.lang.String servletPath)
servletPath - The servletPath to set.public void setSession(HttpSession session)
session - The session to set.public void setSessionHandler(SessionHandler sessionHandler)
sessionHandler - The SessionHandler to set.public void setTimeStamp(long ts)
public void setUserIdentityScope(UserIdentity.Scope scope)
public AsyncContext startAsync() throws java.lang.IllegalStateException
startAsync in interface ServletRequestjava.lang.IllegalStateExceptionpublic AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws java.lang.IllegalStateException
startAsync in interface ServletRequestjava.lang.IllegalStateExceptionpublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean authenticate(HttpServletResponse response) throws java.io.IOException, ServletException
authenticate in interface HttpServletRequestjava.io.IOExceptionServletExceptionpublic Part getPart(java.lang.String name) throws java.io.IOException, ServletException
getPart in interface HttpServletRequestjava.io.IOExceptionServletExceptionpublic java.util.Collection<Part> getParts() throws java.io.IOException, ServletException
getParts in interface HttpServletRequestjava.io.IOExceptionServletExceptionpublic void login(java.lang.String username,
java.lang.String password)
throws ServletException
login in interface HttpServletRequestServletExceptionpublic void logout()
throws ServletException
logout in interface HttpServletRequestServletExceptionpublic void mergeQueryParameters(java.lang.String oldQuery,
java.lang.String newQuery,
boolean updateQueryString)
public <T extends HttpUpgradeHandler> T upgrade(java.lang.Class<T> handlerClass) throws java.io.IOException, ServletException
upgrade in interface HttpServletRequestjava.io.IOExceptionServletExceptionHttpServletRequest.upgrade(java.lang.Class)Copyright © 1995–2018 Webtide. All rights reserved.