Package org.eclipse.jetty.client.api
Interface Response.Listener
-
- All Superinterfaces:
java.util.EventListener,Response.AsyncContentListener,Response.BeginListener,Response.CompleteListener,Response.ContentListener,Response.DemandedContentListener,Response.FailureListener,Response.HeaderListener,Response.HeadersListener,Response.ResponseListener,Response.SuccessListener
- All Known Implementing Classes:
BufferingResponseListener,ContinueProtocolHandler.ContinueListener,FutureResponseListener,InputStreamResponseListener,RedirectProtocolHandler,Response.Listener.Adapter
- Enclosing interface:
- Response
public static interface Response.Listener extends Response.BeginListener, Response.HeaderListener, Response.HeadersListener, Response.ContentListener, Response.AsyncContentListener, Response.DemandedContentListener, Response.SuccessListener, Response.FailureListener, Response.CompleteListener
Listener for all response events.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classResponse.Listener.AdapterAn empty implementation ofResponse.Listener
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default voidonBeforeContent(Response response, java.util.function.LongConsumer demand)Callback method invoked before response content events.default voidonBegin(Response response)Callback method invoked when the response line containing HTTP version, HTTP status code and reason has been received and parsed.default voidonComplete(Result result)Callback method invoked when the request and the response have been processed, either successfully or not.default voidonContent(Response response, java.nio.ByteBuffer content)Callback method invoked when the response content has been received, parsed and there is demand.default voidonContent(Response response, java.nio.ByteBuffer content, org.eclipse.jetty.util.Callback callback)Callback method invoked when the response content has been received, parsed and there is demand.default voidonContent(Response response, java.util.function.LongConsumer demand, java.nio.ByteBuffer content, org.eclipse.jetty.util.Callback callback)Callback method invoked when the response content has been received.default voidonFailure(Response response, java.lang.Throwable failure)Callback method invoked when the response has failed in the process of being receiveddefault booleanonHeader(Response response, HttpField field)Callback method invoked when a response header has been received and parsed, returning whether the header should be processed or not.default voidonHeaders(Response response)Callback method invoked when all the response headers have been received and parsed.default voidonSuccess(Response response)Callback method invoked when the whole response has been successfully received.
-
-
-
Method Detail
-
onBegin
default void onBegin(Response response)
Description copied from interface:Response.BeginListenerCallback method invoked when the response line containing HTTP version, HTTP status code and reason has been received and parsed.This method is the best approximation to detect when the first bytes of the response arrived to the client.
- Specified by:
onBeginin interfaceResponse.BeginListener- Parameters:
response- the response containing the response line data
-
onHeader
default boolean onHeader(Response response, HttpField field)
Description copied from interface:Response.HeaderListenerCallback method invoked when a response header has been received and parsed, returning whether the header should be processed or not.- Specified by:
onHeaderin interfaceResponse.HeaderListener- Parameters:
response- the response containing the response line data and the headers so farfield- the header received- Returns:
- true to process the header, false to skip processing of the header
-
onHeaders
default void onHeaders(Response response)
Description copied from interface:Response.HeadersListenerCallback method invoked when all the response headers have been received and parsed.- Specified by:
onHeadersin interfaceResponse.HeadersListener- Parameters:
response- the response containing the response line data and the headers
-
onBeforeContent
default void onBeforeContent(Response response, java.util.function.LongConsumer demand)
Description copied from interface:Response.DemandedContentListenerCallback method invoked before response content events. Thedemandobject should be used to demand content, otherwise the demand remains at zero (no demand) andResponse.DemandedContentListener.onContent(Response, LongConsumer, ByteBuffer, Callback)will not be invoked even if content has been received and parsed.- Specified by:
onBeforeContentin interfaceResponse.DemandedContentListener- Parameters:
response- the response containing the response line data and the headersdemand- the object that allows to demand content buffers
-
onContent
default void onContent(Response response, java.nio.ByteBuffer content)
Description copied from interface:Response.ContentListenerCallback method invoked when the response content has been received, parsed and there is demand. This method may be invoked multiple times, and thecontentbuffer must be consumed (or copied) before returning from this method.- Specified by:
onContentin interfaceResponse.ContentListener- Parameters:
response- the response containing the response line data and the headerscontent- the content bytes received
-
onContent
default void onContent(Response response, java.nio.ByteBuffer content, org.eclipse.jetty.util.Callback callback)
Description copied from interface:Response.AsyncContentListenerCallback method invoked when the response content has been received, parsed and there is demand. Thecallbackobject should be succeeded to signal that thecontentbuffer has been consumed and to demand more content.- Specified by:
onContentin interfaceResponse.AsyncContentListener- Parameters:
response- the response containing the response line data and the headerscontent- the content bytes receivedcallback- the callback to call when the content is consumed and to demand more content
-
onContent
default void onContent(Response response, java.util.function.LongConsumer demand, java.nio.ByteBuffer content, org.eclipse.jetty.util.Callback callback)
Description copied from interface:Response.DemandedContentListenerCallback method invoked when the response content has been received. Thecallbackobject should be succeeded to signal that thecontentbuffer has been consumed. Thedemandobject should be used to demand more content, similarly to ReactiveStreams'sSubscription#request(long).- Specified by:
onContentin interfaceResponse.DemandedContentListener- Parameters:
response- the response containing the response line data and the headersdemand- the object that allows to demand content bufferscontent- the content bytes receivedcallback- the callback to call when the content is consumed
-
onSuccess
default void onSuccess(Response response)
Description copied from interface:Response.SuccessListenerCallback method invoked when the whole response has been successfully received.- Specified by:
onSuccessin interfaceResponse.SuccessListener- Parameters:
response- the response containing the response line data and the headers
-
onFailure
default void onFailure(Response response, java.lang.Throwable failure)
Description copied from interface:Response.FailureListenerCallback method invoked when the response has failed in the process of being received- Specified by:
onFailurein interfaceResponse.FailureListener- Parameters:
response- the response containing data up to the point the failure happenedfailure- the failure happened
-
onComplete
default void onComplete(Result result)
Description copied from interface:Response.CompleteListenerCallback method invoked when the request and the response have been processed, either successfully or not.The
resultparameter contains the request, the response, and eventual failures.Requests may complete after response, for example in case of big uploads that are discarded or read asynchronously by the server. This method is always invoked after
Response.SuccessListener.onSuccess(Response)orResponse.FailureListener.onFailure(Response, Throwable), and only when request indicates that it is completed.- Specified by:
onCompletein interfaceResponse.CompleteListener- Parameters:
result- the result of the request / response exchange
-
-