Class Request.Wrapper

java.lang.Object
org.eclipse.jetty.server.Request.Wrapper
All Implemented Interfaces:
org.eclipse.jetty.io.Content.Source, Request, org.eclipse.jetty.util.Attributes
Direct Known Subclasses:
ContextRequest, GzipRequest, HeaderWrappingRequest, Request.AttributesWrapper, SecureRequestCustomizer.SecureRequest, StatisticsHandler.MinimumDataRateHandler.MinimumDataRateRequest
Enclosing interface:
Request

public static class Request.Wrapper extends Object implements Request

A wrapper for Request instances.

  • Constructor Details

    • Wrapper

      public Wrapper(Request wrapped)
  • Method Details

    • getId

      public String getId()
      Description copied from interface: Request
      an ID unique within the lifetime scope of the ConnectionMetaData.getId()). This may be a protocol ID (e.g. HTTP/2 stream ID) or it may be unrelated to the protocol.
      Specified by:
      getId in interface Request
      See Also:
    • getComponents

      public Components getComponents()
      Specified by:
      getComponents in interface Request
      Returns:
      the Components to be used with this Request.
    • getConnectionMetaData

      public ConnectionMetaData getConnectionMetaData()
      Specified by:
      getConnectionMetaData in interface Request
      Returns:
      the ConnectionMetaData associated to this Request
    • getMethod

      public String getMethod()
      Specified by:
      getMethod in interface Request
      Returns:
      the HTTP method of this Request
    • getHttpURI

      public org.eclipse.jetty.http.HttpURI getHttpURI()
      Specified by:
      getHttpURI in interface Request
      Returns:
      the HTTP URI of this Request
      See Also:
    • getContext

      public Context getContext()
      Description copied from interface: Request
      Get the Context associated with this Request.

      Note that a Request should always have an associated Context since if the Request is not being handled by a ContextHandler then the Context from Server.getContext() will be used.

      Specified by:
      getContext in interface Request
      Returns:
      the Context associated with this Request. Never null.
      See Also:
    • getHeaders

      public org.eclipse.jetty.http.HttpFields getHeaders()
      Specified by:
      getHeaders in interface Request
      Returns:
      the HTTP headers of this Request
    • getTrailers

      public org.eclipse.jetty.http.HttpFields getTrailers()
      Specified by:
      getTrailers in interface Request
      Returns:
      the HTTP trailers of this Request, or null if they are not present
    • getBeginNanoTime

      public long getBeginNanoTime()
      Description copied from interface: Request

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

      Specified by:
      getBeginNanoTime in interface Request
      Returns:
      The nanoTime at which the request was received/created in nanoseconds
    • getHeadersNanoTime

      public long getHeadersNanoTime()
      Description copied from interface: Request

      Get the nanoTime at which the request headers were parsed, obtained via System.nanoTime(). This method can be used when measuring latencies.

      Specified by:
      getHeadersNanoTime in interface Request
      Returns:
      The nanoTime at which the request was ready in nanoseconds
    • isSecure

      public boolean isSecure()
      Specified by:
      isSecure in interface Request
    • getLength

      public long getLength()
      Specified by:
      getLength in interface org.eclipse.jetty.io.Content.Source
    • read

      public org.eclipse.jetty.io.Content.Chunk read()
      Description copied from interface: Request

      In addition, the returned Content.Chunk may be a Trailers instance, in case of request content trailers.

      Specified by:
      read in interface org.eclipse.jetty.io.Content.Source
      Specified by:
      read in interface Request
    • consumeAvailable

      public boolean consumeAvailable()
      Description copied from interface: Request
      Consume any available content. This bypasses any request wrappers to process the content in Request.read() and reads directly from the HttpStream. This reads until there is no content currently available, or it reaches EOF. The HttpConfiguration.setMaxUnconsumedRequestContentReads(int) configuration can be used to configure how many reads will be attempted by this method.
      Specified by:
      consumeAvailable in interface Request
      Returns:
      true if the content was fully consumed.
    • demand

      public void demand(Runnable demandCallback)
      Description copied from interface: Request
      Specified by:
      demand in interface org.eclipse.jetty.io.Content.Source
      Specified by:
      demand in interface Request
      Parameters:
      demandCallback - the demand callback to invoke when there is a content chunk available.
      See Also:
      • Content.Source.demand(Runnable)
    • fail

      public void fail(Throwable failure)
      Specified by:
      fail in interface org.eclipse.jetty.io.Content.Source
    • push

      public void push(org.eclipse.jetty.http.MetaData.Request resource)
      Description copied from interface: Request

      Pushes the given resource to the client.

      Specified by:
      push in interface Request
      Parameters:
      resource - the resource to push
      See Also:
    • addIdleTimeoutListener

      public void addIdleTimeoutListener(Predicate<TimeoutException> onIdleTimeout)
      Description copied from interface: Request

      Adds a listener for idle timeouts.

      The listener is a predicate function that should return true to indicate that the idle timeout should be handled by the container as a fatal failure (see Request.addFailureListener(Consumer)); or false to ignore that specific timeout and for another timeout to occur after another idle period.

      Idle timeout listeners are only invoked if there are no pending Request.demand(Runnable) or Response.write(boolean, ByteBuffer, Callback) operations.

      Listeners are processed in the same order they are added, and the first that returns true stops the processing of subsequent listeners, which are therefore not invoked.

      Specified by:
      addIdleTimeoutListener in interface Request
      Parameters:
      onIdleTimeout - the idle timeout listener as a predicate function
      See Also:
    • addFailureListener

      public void addFailureListener(Consumer<Throwable> onFailure)
      Description copied from interface: Request

      Adds a listener for asynchronous fatal failures.

      When a listener is called, the effects of the failure have already taken place:

      Listeners are processed in the same order they are added.

      Specified by:
      addFailureListener in interface Request
      Parameters:
      onFailure - the failure listener as a consumer function
      See Also:
    • getTunnelSupport

      public TunnelSupport getTunnelSupport()
      Specified by:
      getTunnelSupport in interface Request
    • addHttpStreamWrapper

      public void addHttpStreamWrapper(Function<HttpStream,HttpStream> wrapper)
      Description copied from interface: Request
      Add a HttpStream.Wrapper to the current HttpStream.
      Specified by:
      addHttpStreamWrapper in interface Request
      Parameters:
      wrapper - A function that wraps the passed stream.
      See Also:
    • getSession

      public Session getSession(boolean create)
      Description copied from interface: Request

      Get a Session associated with the request. Sessions may not be supported by a given configuration, in which case null will be returned.

      Specified by:
      getSession in interface Request
      Parameters:
      create - True if the session should be created for the request.
      Returns:
      The session associated with the request or null.
    • removeAttribute

      public Object removeAttribute(String name)
      Specified by:
      removeAttribute in interface org.eclipse.jetty.util.Attributes
    • setAttribute

      public Object setAttribute(String name, Object attribute)
      Specified by:
      setAttribute in interface org.eclipse.jetty.util.Attributes
    • getAttribute

      public Object getAttribute(String name)
      Specified by:
      getAttribute in interface org.eclipse.jetty.util.Attributes
    • getAttributeNameSet

      public Set<String> getAttributeNameSet()
      Specified by:
      getAttributeNameSet in interface org.eclipse.jetty.util.Attributes
    • asAttributeMap

      public Map<String,Object> asAttributeMap()
      Specified by:
      asAttributeMap in interface org.eclipse.jetty.util.Attributes
    • clearAttributes

      public void clearAttributes()
      Specified by:
      clearAttributes in interface org.eclipse.jetty.util.Attributes
    • getWrapped

      public Request getWrapped()
    • toString

      public String toString()
      Overrides:
      toString in class Object