Class BufferingResponseListener

java.lang.Object
org.eclipse.jetty.client.AbstractResponseListener
org.eclipse.jetty.client.BufferingResponseListener
All Implemented Interfaces:
EventListener, Response.AsyncContentListener, Response.BeginListener, Response.CompleteListener, Response.ContentListener, Response.ContentSourceListener, Response.FailureListener, Response.HeaderListener, Response.HeadersListener, Response.Listener, Response.ResponseListener, Response.SuccessListener

public abstract class BufferingResponseListener extends AbstractResponseListener

Implementation of Response.Listener that buffers the response content by copying it up to a maximum length specified to the constructors.

The content may be retrieved from AbstractResponseListener.onSuccess(Response) or Response.Listener.onComplete(Result) via AbstractResponseListener.getContent() or AbstractResponseListener.getContentAsString().

Instances of this class are not reusable, so one must be allocated for each request.

Use RetainingResponseListener for a more efficient implementation that does not copy the content bytes.

  • Constructor Details

    • BufferingResponseListener

      public BufferingResponseListener()
      Creates an instance with a default maximum length of 2 MiB.
    • BufferingResponseListener

      public BufferingResponseListener(int maxLength)
      Creates an instance with the given maximum length
      Parameters:
      maxLength - the maximum length of the content