Class Request.Wrapper

java.lang.Object
org.eclipse.jetty.util.Attributes.Wrapper
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, ErrorHandler.ErrorRequest, GzipRequest, HeaderWrappingRequest, SecureRequestCustomizer.SecureRequest, StatisticsHandler.MinimumDataRateHandler.MinimumDataRateRequest
Enclosing interface:
Request

public static class Request.Wrapper extends org.eclipse.jetty.util.Attributes.Wrapper 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. In addition to the invocation guarantees of Content.Source.demand(Runnable), this implementation serializes the invocation of the Runnable with invocations of any Response.write(boolean, ByteBuffer, Callback) Callback invocations.
      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 hard failure (see Request.addFailureListener(Consumer)); or false to ignore that specific timeout and for another timeout to occur after another idle period.

      Any pending Request.demand(Runnable) or Response.write(boolean, ByteBuffer, Callback) operations are not affected by this call. Applications need to be mindful of any such pending operations if attempting to make new operations.

      Listeners are processed in sequence, 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 predicate function
      See Also:
    • addFailureListener

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

      Adds a listener for asynchronous hard errors.

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

      Listeners are processed in sequence. When all listeners are invoked then Callback.failed(Throwable) will be called on the callback passed to Request.Handler.handle(Request, Response, Callback).

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

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

      public void addHttpStreamWrapper(Function<HttpStream,HttpStream> wrapper)
      Specified by:
      addHttpStreamWrapper in interface Request
    • 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.
    • getWrapped

      public Request getWrapped()
      Overrides:
      getWrapped in class org.eclipse.jetty.util.Attributes.Wrapper