@ThreadSafe public class BasicAsyncResponseProducer extends java.lang.Object implements HttpAsyncResponseProducer
HttpAsyncResponseProducer. The producer
can make use of the HttpAsyncContentProducer interface to
efficiently stream out message content to the underlying non-blocking HTTP
connection, if it is implemented by the HttpEntity inclosed in
the response.HttpAsyncContentProducer| 限定符 | 构造器和说明 |
|---|---|
|
BasicAsyncResponseProducer(HttpResponse response)
Creates a producer that can be used to transmit the given response
message.
|
protected |
BasicAsyncResponseProducer(HttpResponse response,
HttpAsyncContentProducer producer)
Creates a producer that can be used to transmit the given response
message.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close() |
void |
failed(java.lang.Exception ex)
Invoked to signal that the response processing terminated abnormally.
|
HttpResponse |
generateResponse()
Invoked to generate a HTTP response message head.
|
void |
produceContent(ContentEncoder encoder,
IOControl ioctrl)
Invoked to write out a chunk of content to the
ContentEncoder. |
void |
responseCompleted(HttpContext context)
Invoked to signal that the response has been fully written out.
|
protected BasicAsyncResponseProducer(HttpResponse response, HttpAsyncContentProducer producer)
HttpEntity whose properties are consistent with the behavior
of the content producer.response - response message.producer - response content producer.public BasicAsyncResponseProducer(HttpResponse response)
HttpEntity
it is also expected to implement HttpAsyncContentProducer.response - response message.public HttpResponse generateResponse()
HttpAsyncResponseProducergenerateResponse 在接口中 HttpAsyncResponseProducerpublic void produceContent(ContentEncoder encoder, IOControl ioctrl) throws java.io.IOException
HttpAsyncResponseProducerContentEncoder.
The IOControl interface can be used to suspend output event
notifications if the producer is temporarily unable to produce more content.
When all content is finished, the producer MUST call
ContentEncoder.complete(). Failure to do so may cause the entity
to be incorrectly delimited.
Please note that the ContentEncoder object is not thread-safe and
should only be used within the context of this method call.
The IOControl object can be shared and used on extension thread
to resume output event notifications when more content is made available.produceContent 在接口中 HttpAsyncResponseProducerencoder - content encoder.ioctrl - I/O control of the underlying connection.java.io.IOException - in case of an I/O errorpublic void responseCompleted(HttpContext context)
HttpAsyncResponseProducerresponseCompleted 在接口中 HttpAsyncResponseProducercontext - HTTP contextpublic void failed(java.lang.Exception ex)
HttpAsyncResponseProducerfailed 在接口中 HttpAsyncResponseProducerex - exceptionpublic void close()
throws java.io.IOException
close 在接口中 java.io.Closeableclose 在接口中 java.lang.AutoCloseablejava.io.IOException