public static interface Response.Listener extends Response.BeginListener, Response.HeaderListener, Response.HeadersListener, Response.ContentListener, Response.AsyncContentListener, Response.DemandedContentListener, Response.SuccessListener, Response.FailureListener, Response.CompleteListener
| Modifier and Type | Interface and Description |
|---|---|
static class |
Response.Listener.Adapter
An empty implementation of
Response.Listener |
| Modifier and Type | Method and Description |
|---|---|
default void |
onBeforeContent(Response response,
java.util.function.LongConsumer demand)
Callback method invoked before response content events.
|
default void |
onBegin(Response response)
Callback method invoked when the response line containing HTTP version,
HTTP status code and reason has been received and parsed.
|
default void |
onComplete(Result result)
Callback method invoked when the request and the response have been processed,
either successfully or not.
|
default void |
onContent(Response response,
java.nio.ByteBuffer content)
Callback method invoked when the response content has been received, parsed and there is demand.
|
default void |
onContent(Response response,
java.nio.ByteBuffer content,
Callback callback)
Callback method invoked when the response content has been received, parsed and there is demand.
|
default void |
onContent(Response response,
java.util.function.LongConsumer demand,
java.nio.ByteBuffer content,
Callback callback)
Callback method invoked when the response content has been received.
|
default void |
onFailure(Response response,
java.lang.Throwable failure)
Callback method invoked when the response has failed in the process of being received
|
default boolean |
onHeader(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 void |
onHeaders(Response response)
Callback method invoked when all the response headers have been received and parsed.
|
default void |
onSuccess(Response response)
Callback method invoked when the whole response has been successfully received.
|
default void onBegin(Response response)
Response.BeginListenerThis method is the best approximation to detect when the first bytes of the response arrived to the client.
onBegin in interface Response.BeginListenerresponse - the response containing the response line datadefault boolean onHeader(Response response, HttpField field)
Response.HeaderListeneronHeader in interface Response.HeaderListenerresponse - the response containing the response line data and the headers so farfield - the header receiveddefault void onHeaders(Response response)
Response.HeadersListeneronHeaders in interface Response.HeadersListenerresponse - the response containing the response line data and the headersdefault void onBeforeContent(Response response, java.util.function.LongConsumer demand)
Response.DemandedContentListenerdemand object should be used to demand content, otherwise
the demand remains at zero (no demand) and
Response.DemandedContentListener.onContent(Response, LongConsumer, ByteBuffer, Callback) will
not be invoked even if content has been received and parsed.onBeforeContent in interface Response.DemandedContentListenerresponse - the response containing the response line data and the headersdemand - the object that allows to demand content buffersdefault void onContent(Response response, java.nio.ByteBuffer content)
Response.ContentListenercontent buffer
must be consumed (or copied) before returning from this method.onContent in interface Response.ContentListenerresponse - the response containing the response line data and the headerscontent - the content bytes receiveddefault void onContent(Response response, java.nio.ByteBuffer content, Callback callback)
Response.AsyncContentListenercallback object should be succeeded to signal that the
content buffer has been consumed and to demand more content.onContent in interface Response.AsyncContentListenerresponse - 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 contentdefault void onContent(Response response, java.util.function.LongConsumer demand, java.nio.ByteBuffer content, Callback callback)
Response.DemandedContentListenercallback object should be succeeded to signal that the
content buffer has been consumed.
The demand object should be used to demand more content,
similarly to ReactiveStreams's Subscription#request(long).onContent in interface Response.DemandedContentListenerresponse - 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 consumeddefault void onSuccess(Response response)
Response.SuccessListeneronSuccess in interface Response.SuccessListenerresponse - the response containing the response line data and the headersdefault void onFailure(Response response, java.lang.Throwable failure)
Response.FailureListeneronFailure in interface Response.FailureListenerresponse - the response containing data up to the point the failure happenedfailure - the failure happeneddefault void onComplete(Result result)
Response.CompleteListener
The result parameter 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) or
Response.FailureListener.onFailure(Response, Throwable), and only when request indicates that
it is completed.
onComplete in interface Response.CompleteListenerresult - the result of the request / response exchangeCopyright © 1995–2020 Webtide. All rights reserved.