public class ResponseListenerProcessor<T> extends AbstractSingleProcessor<T,T> implements org.eclipse.jetty.client.api.Response.Listener
A Processor that listens for response events.
When this Processor is demanded data, it first sends the request and produces no data. When the response arrives, the application is invoked with a Publisher that produces response content chunks.
The application processes the response content chunks into some other data structure (for example, splits them further, or coalesce them into a single chunk) and returns the application Processor to this implementation, which then builds this chain:
HTTP response content chunks Publisher - (produces ContentChunks)
Application Processor - (processes ContentChunks and produces Ts)
ResponseListenerProcessor - (forwards Ts to application)
Application Subscriber - (consumes Ts)
Data flows from top to bottom, demand from bottom to top.
ResponseListenerProcessor acts as a "hot" publisher: it is returned to the application before the response content arrives so that the application can subscribe to it.
Any further data demand to this Processor is forwarded to the Application Processor, which in turn demands response content chunks. Response content chunks arrive to the Application Processor, which processes them and produces data that is forwarded to this Processor, which forwards it to the Application Subscriber.
| Constructor and Description |
|---|
ResponseListenerProcessor(ReactiveRequest request,
BiFunction<ReactiveResponse,org.reactivestreams.Publisher<ContentChunk>,org.reactivestreams.Publisher<T>> contentFn,
boolean abortOnCancel) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel() |
void |
onBeforeContent(org.eclipse.jetty.client.api.Response response,
LongConsumer demand) |
void |
onBegin(org.eclipse.jetty.client.api.Response response) |
void |
onComplete(org.eclipse.jetty.client.api.Result result) |
void |
onContent(org.eclipse.jetty.client.api.Response response,
ByteBuffer content) |
void |
onContent(org.eclipse.jetty.client.api.Response response,
ByteBuffer buffer,
org.eclipse.jetty.util.Callback callback) |
void |
onContent(org.eclipse.jetty.client.api.Response response,
LongConsumer demand,
ByteBuffer buffer,
org.eclipse.jetty.util.Callback callback) |
void |
onFailure(org.eclipse.jetty.client.api.Response response,
Throwable failure) |
boolean |
onHeader(org.eclipse.jetty.client.api.Response response,
org.eclipse.jetty.http.HttpField field) |
void |
onHeaders(org.eclipse.jetty.client.api.Response response) |
void |
onNext(T t) |
protected void |
onRequest(org.reactivestreams.Subscriber<? super T> subscriber,
long n) |
void |
onSuccess(org.eclipse.jetty.client.api.Response response) |
String |
toString() |
downStream, downStreamOnNext, onComplete, onError, onFailure, onSubscribe, upStream, upStreamRequestisCancelled, request, subscribe, subscriberpublic ResponseListenerProcessor(ReactiveRequest request, BiFunction<ReactiveResponse,org.reactivestreams.Publisher<ContentChunk>,org.reactivestreams.Publisher<T>> contentFn, boolean abortOnCancel)
public void onBegin(org.eclipse.jetty.client.api.Response response)
onBegin in interface org.eclipse.jetty.client.api.Response.BeginListeneronBegin in interface org.eclipse.jetty.client.api.Response.Listenerpublic boolean onHeader(org.eclipse.jetty.client.api.Response response,
org.eclipse.jetty.http.HttpField field)
onHeader in interface org.eclipse.jetty.client.api.Response.HeaderListeneronHeader in interface org.eclipse.jetty.client.api.Response.Listenerpublic void onHeaders(org.eclipse.jetty.client.api.Response response)
onHeaders in interface org.eclipse.jetty.client.api.Response.HeadersListeneronHeaders in interface org.eclipse.jetty.client.api.Response.Listenerpublic void onBeforeContent(org.eclipse.jetty.client.api.Response response,
LongConsumer demand)
onBeforeContent in interface org.eclipse.jetty.client.api.Response.DemandedContentListenerpublic void onContent(org.eclipse.jetty.client.api.Response response,
ByteBuffer content)
onContent in interface org.eclipse.jetty.client.api.Response.ContentListeneronContent in interface org.eclipse.jetty.client.api.Response.Listenerpublic void onContent(org.eclipse.jetty.client.api.Response response,
ByteBuffer buffer,
org.eclipse.jetty.util.Callback callback)
onContent in interface org.eclipse.jetty.client.api.Response.AsyncContentListeneronContent in interface org.eclipse.jetty.client.api.Response.ContentListenerpublic void onContent(org.eclipse.jetty.client.api.Response response,
LongConsumer demand,
ByteBuffer buffer,
org.eclipse.jetty.util.Callback callback)
onContent in interface org.eclipse.jetty.client.api.Response.AsyncContentListeneronContent in interface org.eclipse.jetty.client.api.Response.DemandedContentListenerpublic void onSuccess(org.eclipse.jetty.client.api.Response response)
onSuccess in interface org.eclipse.jetty.client.api.Response.ListeneronSuccess in interface org.eclipse.jetty.client.api.Response.SuccessListenerpublic void onFailure(org.eclipse.jetty.client.api.Response response,
Throwable failure)
onFailure in interface org.eclipse.jetty.client.api.Response.FailureListeneronFailure in interface org.eclipse.jetty.client.api.Response.Listenerpublic void onComplete(org.eclipse.jetty.client.api.Result result)
onComplete in interface org.eclipse.jetty.client.api.Response.CompleteListeneronComplete in interface org.eclipse.jetty.client.api.Response.Listenerprotected void onRequest(org.reactivestreams.Subscriber<? super T> subscriber, long n)
onRequest in class AbstractSingleProcessor<T,T>public void cancel()
cancel in interface org.reactivestreams.Subscriptioncancel in class AbstractSingleProcessor<T,T>public String toString()
toString in class AbstractSingleProcessor<T,T>Copyright © 2017–2024 The Jetty Project. All rights reserved.