Class Request

java.lang.Object
org.eclipse.jetty.ee8.nested.Request
All Implemented Interfaces:
javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest

public class Request extends Object implements javax.servlet.http.HttpServletRequest
Jetty Request.
  • Field Details

  • Constructor Details

  • Method Details

    • getBaseRequest

      public static Request getBaseRequest(javax.servlet.ServletRequest request)
      Obtain the base Request instance of a ServletRequest, by coercion, unwrapping or special attribute.
      Parameters:
      request - The request
      Returns:
      the base Request instance of a ServletRequest.
    • getHttpFields

      public HttpFields getHttpFields()
    • setHttpFields

      public void setHttpFields(HttpFields fields)
    • getTrailerFields

      public Map<String,String> getTrailerFields()
      Specified by:
      getTrailerFields in interface javax.servlet.http.HttpServletRequest
    • setTrailerHttpFields

      public void setTrailerHttpFields(HttpFields trailers)
    • getTrailerHttpFields

      public HttpFields getTrailerHttpFields()
    • getHttpInput

      public HttpInput getHttpInput()
    • isPush

      public boolean isPush()
    • isPushSupported

      public boolean isPushSupported()
    • newPushBuilder

      public javax.servlet.http.PushBuilder newPushBuilder()
      Specified by:
      newPushBuilder in interface javax.servlet.http.HttpServletRequest
    • addEventListener

      public void addEventListener(EventListener listener)
    • extractFormParameters

      public void extractFormParameters(Fields params)
    • getAsyncContext

      public javax.servlet.AsyncContext getAsyncContext()
      Specified by:
      getAsyncContext in interface javax.servlet.ServletRequest
    • getHttpChannelState

      public HttpChannelState getHttpChannelState()
    • getComplianceViolationListener

      @Deprecated(since="12.0.6", forRemoval=true) public ComplianceViolation.Listener getComplianceViolationListener()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use core level ComplianceViolation.Listener instead. - will be removed in Jetty 12.1.0
    • getAttribute

      public Object getAttribute(String name)
      Get Request Attribute.

      Also supports jetty specific attributes to gain access to Jetty APIs:

      org.eclipse.jetty.server.Server
      The Jetty Server instance
      org.eclipse.jetty.server.HttpChannel
      The HttpChannel for this request
      org.eclipse.jetty.server.HttpConnection
      The HttpConnection or null if another transport is used
      While these attributes may look like security problems, they are exposing nothing that is not already available via reflection from a Request instance.
      Specified by:
      getAttribute in interface javax.servlet.ServletRequest
      See Also:
      • ServletRequest.getAttribute(String)
    • getAttributeNames

      public Enumeration<String> getAttributeNames()
      Specified by:
      getAttributeNames in interface javax.servlet.ServletRequest
    • getAttributes

      public Attributes getAttributes()
    • getAuthentication

      public Authentication getAuthentication()
      Get the authentication.
      Returns:
      the authentication
    • getAuthType

      public String getAuthType()
      Specified by:
      getAuthType in interface javax.servlet.http.HttpServletRequest
    • getCharacterEncoding

      public String getCharacterEncoding()
      Specified by:
      getCharacterEncoding in interface javax.servlet.ServletRequest
    • getHttpChannel

      public HttpChannel getHttpChannel()
      Returns:
      Returns the connection.
    • getContentLength

      public int getContentLength()
      Specified by:
      getContentLength in interface javax.servlet.ServletRequest
    • getContentLengthLong

      public long getContentLengthLong()
      Specified by:
      getContentLengthLong in interface javax.servlet.ServletRequest
    • getContentRead

      public long getContentRead()
    • getContentType

      public String getContentType()
      Specified by:
      getContentType in interface javax.servlet.ServletRequest
    • getContext

      public ContextHandler.APIContext getContext()
      Returns:
      The context used for this request.
    • setContext

      public void setContext(ContextHandler.APIContext context, String pathInContext)
    • getLastContext

      public ContextHandler.APIContext getLastContext()
    • getLastPathInContext

      public String getLastPathInContext()
    • getContextPath

      public String getContextPath()
      Specified by:
      getContextPath in interface javax.servlet.http.HttpServletRequest
    • getPathInContext

      public String getPathInContext()
      Get the path relative to the context path, analogous to getServletPath() + getPathInfo(). If no context is set, then the path in context is the full path.
      Returns:
      The decoded part of the getRequestURI() path after any getContextPath() up to any getQueryString(), excluding path parameters.
    • getCookies

      public javax.servlet.http.Cookie[] getCookies()
      Specified by:
      getCookies in interface javax.servlet.http.HttpServletRequest
    • getDateHeader

      public long getDateHeader(String name)
      Specified by:
      getDateHeader in interface javax.servlet.http.HttpServletRequest
    • getDispatcherType

      public javax.servlet.DispatcherType getDispatcherType()
      Specified by:
      getDispatcherType in interface javax.servlet.ServletRequest
    • getHeader

      public String getHeader(String name)
      Specified by:
      getHeader in interface javax.servlet.http.HttpServletRequest
    • getHeaderNames

      public Enumeration<String> getHeaderNames()
      Specified by:
      getHeaderNames in interface javax.servlet.http.HttpServletRequest
    • getHeaders

      public Enumeration<String> getHeaders(String name)
      Specified by:
      getHeaders in interface javax.servlet.http.HttpServletRequest
    • getInputState

      public int getInputState()
      Returns:
      Returns the inputState.
    • getInputStream

      public javax.servlet.ServletInputStream getInputStream() throws IOException
      Specified by:
      getInputStream in interface javax.servlet.ServletRequest
      Throws:
      IOException
    • getIntHeader

      public int getIntHeader(String name)
      Specified by:
      getIntHeader in interface javax.servlet.http.HttpServletRequest
    • getLocale

      public Locale getLocale()
      Specified by:
      getLocale in interface javax.servlet.ServletRequest
    • getLocales

      public Enumeration<Locale> getLocales()
      Specified by:
      getLocales in interface javax.servlet.ServletRequest
    • getLocalAddr

      public String getLocalAddr()
      Specified by:
      getLocalAddr in interface javax.servlet.ServletRequest
    • getLocalName

      public String getLocalName()
      Specified by:
      getLocalName in interface javax.servlet.ServletRequest
    • getLocalPort

      public int getLocalPort()
      Specified by:
      getLocalPort in interface javax.servlet.ServletRequest
    • getMethod

      public String getMethod()
      Specified by:
      getMethod in interface javax.servlet.http.HttpServletRequest
    • getParameter

      public String getParameter(String name)
      Specified by:
      getParameter in interface javax.servlet.ServletRequest
    • getParameterMap

      public Map<String,String[]> getParameterMap()
      Specified by:
      getParameterMap in interface javax.servlet.ServletRequest
    • getParameterNames

      public Enumeration<String> getParameterNames()
      Specified by:
      getParameterNames in interface javax.servlet.ServletRequest
    • getParameterValues

      public String[] getParameterValues(String name)
      Specified by:
      getParameterValues in interface javax.servlet.ServletRequest
    • getQueryParameters

      @Deprecated public MultiMap<String> getQueryParameters()
      Deprecated.
    • getQueryFields

      public Fields getQueryFields()
    • setQueryFields

      public void setQueryFields(Fields queryParameters)
    • setQueryParameters

      @Deprecated public void setQueryParameters(MultiMap<String> queryParameters)
      Deprecated.
    • setContentFields

      public void setContentFields(Fields contentParameters)
    • setContentParameters

      @Deprecated public void setContentParameters(MultiMap<String> contentParameters)
      Deprecated.
    • resetParameters

      public void resetParameters()
    • getPathInfo

      public String getPathInfo()
      Specified by:
      getPathInfo in interface javax.servlet.http.HttpServletRequest
    • getPathTranslated

      public String getPathTranslated()
      Specified by:
      getPathTranslated in interface javax.servlet.http.HttpServletRequest
    • getProtocol

      public String getProtocol()
      Specified by:
      getProtocol in interface javax.servlet.ServletRequest
    • getHttpVersion

      public HttpVersion getHttpVersion()
    • getQueryEncoding

      public String getQueryEncoding()
    • getQueryString

      public String getQueryString()
      Specified by:
      getQueryString in interface javax.servlet.http.HttpServletRequest
    • getReader

      public BufferedReader getReader() throws IOException
      Specified by:
      getReader in interface javax.servlet.ServletRequest
      Throws:
      IOException
    • getRealPath

      @Deprecated(since="Servlet API 2.1") public String getRealPath(String path)
      Deprecated.
      Specified by:
      getRealPath in interface javax.servlet.ServletRequest
    • getRemoteInetSocketAddress

      public InetSocketAddress getRemoteInetSocketAddress()
      Access the underlying Remote InetSocketAddress for this request.
      Returns:
      the remote InetSocketAddress for this request, or null if the request has no remote (see ServletRequest.getRemoteAddr() for conditions that result in no remote address)
    • getRemoteAddr

      public String getRemoteAddr()
      Specified by:
      getRemoteAddr in interface javax.servlet.ServletRequest
    • getRemoteHost

      public String getRemoteHost()
      Specified by:
      getRemoteHost in interface javax.servlet.ServletRequest
    • getRemotePort

      public int getRemotePort()
      Specified by:
      getRemotePort in interface javax.servlet.ServletRequest
    • getRemoteUser

      public String getRemoteUser()
      Specified by:
      getRemoteUser in interface javax.servlet.http.HttpServletRequest
    • getRequestDispatcher

      public javax.servlet.RequestDispatcher getRequestDispatcher(String path)
      Specified by:
      getRequestDispatcher in interface javax.servlet.ServletRequest
    • getRequestedSessionId

      public String getRequestedSessionId()
      Specified by:
      getRequestedSessionId in interface javax.servlet.http.HttpServletRequest
    • getRequestURI

      public String getRequestURI()
      Specified by:
      getRequestURI in interface javax.servlet.http.HttpServletRequest
    • getRequestURL

      public StringBuffer getRequestURL()
      Specified by:
      getRequestURL in interface javax.servlet.http.HttpServletRequest
    • getResponse

      public Response getResponse()
    • getRootURL

      public StringBuilder getRootURL()
      Reconstructs the URL the client used to make the request. The returned URL contains a protocol, server name, port number, and, but it does not include a path.

      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.

      Returns:
      "scheme://host:port"
    • getScheme

      public String getScheme()
      Specified by:
      getScheme in interface javax.servlet.ServletRequest
    • getServerName

      public String getServerName()
      Specified by:
      getServerName in interface javax.servlet.ServletRequest
    • getServerPort

      public int getServerPort()
      Specified by:
      getServerPort in interface javax.servlet.ServletRequest
    • getServletContext

      public javax.servlet.ServletContext getServletContext()
      Specified by:
      getServletContext in interface javax.servlet.ServletRequest
    • getServletName

      public String getServletName()
    • getServletPath

      public String getServletPath()
      Specified by:
      getServletPath in interface javax.servlet.http.HttpServletRequest
    • getServletResponse

      public javax.servlet.ServletResponse getServletResponse()
    • changeSessionId

      public String changeSessionId()
      Specified by:
      changeSessionId in interface javax.servlet.http.HttpServletRequest
    • onCompleted

      public void onCompleted()
      Called when the request is fully finished being handled. For every session in any context that the session has accessed, ensure that the session is completed.
    • getSession

      public javax.servlet.http.HttpSession getSession(SessionManager sessionManager)
      Find a session that this request has already entered for the given SessionHandler
      Parameters:
      sessionManager - the SessionHandler (ie context) to check
      Returns:
      the session for the passed session handler or null
    • getSession

      public javax.servlet.http.HttpSession getSession()
      Specified by:
      getSession in interface javax.servlet.http.HttpServletRequest
    • getSession

      public javax.servlet.http.HttpSession getSession(boolean create)
      Specified by:
      getSession in interface javax.servlet.http.HttpServletRequest
    • getTimeStamp

      public long getTimeStamp()
      Get Request TimeStamp
      Returns:
      The time that the request was received.
    • getHttpURI

      public HttpURI getHttpURI()
    • setHttpURI

      public void setHttpURI(HttpURI uri)
    • getOriginalURI

      public String getOriginalURI()
      Returns:
      Returns the original uri passed in metadata before customization/rewrite
    • getUserIdentity

      public UserIdentity getUserIdentity()
    • getResolvedUserIdentity

      public UserIdentity getResolvedUserIdentity()
      Returns:
      The resolved user Identity, which may be null if the Authentication is not Authentication.User (eg. Authentication.Deferred).
    • getUserIdentityScope

      public UserIdentityScope getUserIdentityScope()
    • getUserPrincipal

      public Principal getUserPrincipal()
      Specified by:
      getUserPrincipal in interface javax.servlet.http.HttpServletRequest
    • isHandled

      public boolean isHandled()
    • isAsyncStarted

      public boolean isAsyncStarted()
      Specified by:
      isAsyncStarted in interface javax.servlet.ServletRequest
    • isAsyncSupported

      public boolean isAsyncSupported()
      Specified by:
      isAsyncSupported in interface javax.servlet.ServletRequest
    • isRequestedSessionIdFromCookie

      public boolean isRequestedSessionIdFromCookie()
      Specified by:
      isRequestedSessionIdFromCookie in interface javax.servlet.http.HttpServletRequest
    • isRequestedSessionIdFromUrl

      @Deprecated(since="Servlet API 2.1") public boolean isRequestedSessionIdFromUrl()
      Deprecated.
      Specified by:
      isRequestedSessionIdFromUrl in interface javax.servlet.http.HttpServletRequest
    • isRequestedSessionIdFromURL

      public boolean isRequestedSessionIdFromURL()
      Specified by:
      isRequestedSessionIdFromURL in interface javax.servlet.http.HttpServletRequest
    • isRequestedSessionIdValid

      public boolean isRequestedSessionIdValid()
      Specified by:
      isRequestedSessionIdValid in interface javax.servlet.http.HttpServletRequest
    • isSecure

      public boolean isSecure()
      Specified by:
      isSecure in interface javax.servlet.ServletRequest
    • setSecure

      public void setSecure(boolean secure)
    • getBeginNanoTime

      public long getBeginNanoTime()

      Get the nanoTime at which the request arrived to a connector, obtained via System.nanoTime(). This method can be used when measuring latencies.

      Returns:
      The nanoTime at which the request was received/created in nanoseconds
    • isUserInRole

      public boolean isUserInRole(String role)
      Specified by:
      isUserInRole in interface javax.servlet.http.HttpServletRequest
    • getCoreRequest

      public ContextHandler.CoreContextRequest getCoreRequest()
    • getMetaData

      public MetaData.Request getMetaData()
    • hasMetaData

      public boolean hasMetaData()
    • recycle

      protected void recycle()
    • removeAttribute

      public void removeAttribute(String name)
      Specified by:
      removeAttribute in interface javax.servlet.ServletRequest
    • removeEventListener

      public void removeEventListener(EventListener listener)
    • setAsyncSupported

      public void setAsyncSupported(boolean supported, Object source)
    • setAttribute

      public void setAttribute(String name, Object value)
      Set a request attribute. if the attribute name is "org.eclipse.jetty.server.server.Request.queryEncoding" then the value is also passed in a call to setQueryEncoding(java.lang.String).
      Specified by:
      setAttribute in interface javax.servlet.ServletRequest
      See Also:
      • ServletRequest.setAttribute(String, Object)
    • setAttributes

      public void setAttributes(Attributes attributes)
      Set the attributes for the request.
      Parameters:
      attributes - The attributes, which must be a Attributes.Wrapper for which Attributes.unwrap(Attributes) will return the original ServletAttributes.
    • setAsyncAttributes

      public void setAsyncAttributes()
    • setAuthentication

      public void setAuthentication(Authentication authentication)
      Set the authentication.
      Parameters:
      authentication - the authentication to set
    • setCharacterEncoding

      public void setCharacterEncoding(String encoding) throws UnsupportedEncodingException
      Specified by:
      setCharacterEncoding in interface javax.servlet.ServletRequest
      Throws:
      UnsupportedEncodingException
    • setCharacterEncodingUnchecked

      public void setCharacterEncodingUnchecked(String encoding)
    • setContentType

      public void setContentType(String contentType)
    • setDispatcherType

      public void setDispatcherType(javax.servlet.DispatcherType type)
    • setHandled

      public void setHandled(boolean h)
    • setMethod

      public void setMethod(String method)
      Parameters:
      method - The method to set.
    • isHead

      public boolean isHead()
    • setQueryEncoding

      public void setQueryEncoding(String queryEncoding)
      Set the character encoding used for the query string. This call will effect the return of getQueryString and getParameters. It must be called before any getParameter methods.

      The request attribute "org.eclipse.jetty.server.Request.queryEncoding" may be set as an alternate method of calling setQueryEncoding.

      Parameters:
      queryEncoding - the URI query character encoding
    • setTimeStamp

      public void setTimeStamp(long ts)
    • setUserIdentityScope

      public void setUserIdentityScope(UserIdentityScope scope)
    • startAsync

      public javax.servlet.AsyncContext startAsync() throws IllegalStateException
      Specified by:
      startAsync in interface javax.servlet.ServletRequest
      Throws:
      IllegalStateException
    • startAsync

      public javax.servlet.AsyncContext startAsync(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse) throws IllegalStateException
      Specified by:
      startAsync in interface javax.servlet.ServletRequest
      Throws:
      IllegalStateException
    • unwrap

      public static javax.servlet.http.HttpServletRequest unwrap(javax.servlet.ServletRequest servletRequest)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • authenticate

      public boolean authenticate(javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException
      Specified by:
      authenticate in interface javax.servlet.http.HttpServletRequest
      Throws:
      IOException
      javax.servlet.ServletException
    • getPart

      public javax.servlet.http.Part getPart(String name) throws IOException, javax.servlet.ServletException
      Specified by:
      getPart in interface javax.servlet.http.HttpServletRequest
      Throws:
      IOException
      javax.servlet.ServletException
    • getParts

      public Collection<javax.servlet.http.Part> getParts() throws IOException, javax.servlet.ServletException
      Specified by:
      getParts in interface javax.servlet.http.HttpServletRequest
      Throws:
      IOException
      javax.servlet.ServletException
    • login

      public void login(String username, String password) throws javax.servlet.ServletException
      Specified by:
      login in interface javax.servlet.http.HttpServletRequest
      Throws:
      javax.servlet.ServletException
    • logout

      public void logout() throws javax.servlet.ServletException
      Specified by:
      logout in interface javax.servlet.http.HttpServletRequest
      Throws:
      javax.servlet.ServletException
    • mergeQueryParameters

      public void mergeQueryParameters(String oldQuery, String newQuery)
    • upgrade

      public <T extends javax.servlet.http.HttpUpgradeHandler> T upgrade(Class<T> handlerClass) throws IOException, javax.servlet.ServletException
      Specified by:
      upgrade in interface javax.servlet.http.HttpServletRequest
      Throws:
      IOException
      javax.servlet.ServletException
    • setServletPathMapping

      public void setServletPathMapping(ServletPathMapping servletPathMapping)
      Set the servletPathMapping, the servletPath and the pathInfo.
      Parameters:
      servletPathMapping - The mapping used to return from getHttpServletMapping()
    • getServletPathMapping

      public ServletPathMapping getServletPathMapping()
      Returns:
      The mapping for the current target servlet, regardless of dispatch type.
    • getHttpServletMapping

      public javax.servlet.http.HttpServletMapping getHttpServletMapping()
      Specified by:
      getHttpServletMapping in interface javax.servlet.http.HttpServletRequest