public class TargetResponseConsumer extends TargetBase implements org.apache.http.nio.protocol.HttpAsyncResponseConsumer<org.apache.http.HttpResponse>
ResponseProducer
that it can begin responding back to the requesting client.
Note that the ResponseProducer
may actually start responding back to the client even before we have fully read the response content from the remote Target.Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
Logger |
Via
Constructor and Description |
---|
TargetResponseConsumer(ResponseProducer producer,
BufferIOController producersBuffer,
org.apache.http.protocol.HttpContext context,
ScriptObjectMirror endpoint)
Primary constructor
|
Modifier and Type | Method and Description |
---|---|
boolean |
cancel()
This method also notifies the
ResponseProducer about the cancellation by invoking our failed method with an InterruptedIOException . |
void |
close() |
void |
consumeContent(org.apache.http.nio.ContentDecoder decoder,
org.apache.http.nio.IOControl ioctrl)
This method is only called if the response had content (which it typically does).
|
void |
failed(Exception ex)
This method also notifies the
ResponseProducer about this exception. |
Exception |
getException()
This method returns null as any failure will have already been propagated to the
ResponseProducer |
org.apache.http.HttpResponse |
getResult() |
boolean |
isDone() |
void |
responseCompleted(org.apache.http.protocol.HttpContext context)
This method also lets the
ResponseProducer know that we have received all the content from the remote Target. |
void |
responseReceived(org.apache.http.HttpResponse response) |
BuildHeaderRemovalList, CreateHttpViaHeader
public TargetResponseConsumer(ResponseProducer producer, BufferIOController producersBuffer, org.apache.http.protocol.HttpContext context, ScriptObjectMirror endpoint)
producer
- The object that will produce the final response back to the client.producersBuffer
- The buffer which this object will write to, and which the producer will read from.context
- The context of this transaction.endpoint
- If non-null, this is a script endpoint that may wish to alter the response from the target before we send it back to the client.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void responseReceived(org.apache.http.HttpResponse response)
responseReceived
in interface org.apache.http.nio.protocol.HttpAsyncResponseConsumer<org.apache.http.HttpResponse>
public void consumeContent(org.apache.http.nio.ContentDecoder decoder, org.apache.http.nio.IOControl ioctrl) throws IOException
ResponseProducer
that is part of this clientRequest to serverRequest to serverResponse to clientResponse transaction.consumeContent
in interface org.apache.http.nio.protocol.HttpAsyncResponseConsumer<org.apache.http.HttpResponse>
IOException
public void responseCompleted(org.apache.http.protocol.HttpContext context)
ResponseProducer
know that we have received all the content from the remote Target.responseCompleted
in interface org.apache.http.nio.protocol.HttpAsyncResponseConsumer<org.apache.http.HttpResponse>
public void failed(Exception ex)
ResponseProducer
about this exception.failed
in interface org.apache.http.nio.protocol.HttpAsyncResponseConsumer<org.apache.http.HttpResponse>
public boolean cancel()
ResponseProducer
about the cancellation by invoking our failed
method with an InterruptedIOException
.cancel
in interface org.apache.http.concurrent.Cancellable
public org.apache.http.HttpResponse getResult()
getResult
in interface org.apache.http.nio.protocol.HttpAsyncResponseConsumer<org.apache.http.HttpResponse>
public Exception getException()
ResponseProducer
getException
in interface org.apache.http.nio.protocol.HttpAsyncResponseConsumer<org.apache.http.HttpResponse>
public boolean isDone()
isDone
in interface org.apache.http.nio.protocol.HttpAsyncResponseConsumer<org.apache.http.HttpResponse>
Copyright © 2015–2024 Frank Stock. All rights reserved.