public class BasicAsyncRequestProducer extends Object implements HttpAsyncRequestProducer
HttpAsyncRequestProducer. 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 enclosed HttpEntity.HttpAsyncContentProducer| Modifier | Constructor and Description |
|---|---|
protected |
BasicAsyncRequestProducer(HttpHost target,
HttpEntityEnclosingRequest request,
HttpAsyncContentProducer producer)
Creates a producer that can be used to transmit the given request
message.
|
|
BasicAsyncRequestProducer(HttpHost target,
HttpRequest request)
Creates a producer that can be used to transmit the given request
message.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
failed(Exception ex)
Invoked to signal that the response processing terminated abnormally.
|
HttpRequest |
generateRequest()
Invoked to generate a HTTP request message head.
|
HttpHost |
getTarget()
Invoked to obtain the request target host.
|
boolean |
isRepeatable()
Determines whether or not this producer is capable of producing
HTTP request messages more than once.
|
void |
produceContent(ContentEncoder encoder,
IOControl ioControl)
Invoked to write out a chunk of content to the
ContentEncoder. |
void |
requestCompleted(HttpContext context)
Invoked to signal that the request has been fully written out.
|
void |
resetRequest()
Invoked to reset the producer to its initial state.
|
String |
toString() |
protected BasicAsyncRequestProducer(HttpHost target, HttpEntityEnclosingRequest request, HttpAsyncContentProducer producer)
HttpEntity whose properties are consistent with the behavior
of the content producer.target - target host.request - request message.producer - request content producer.public BasicAsyncRequestProducer(HttpHost target, HttpRequest request)
HttpEntity
it is also expected to implement HttpAsyncContentProducer.target - target host.request - request message.public HttpRequest generateRequest()
HttpAsyncRequestProducerHttpEntityEnclosingRequest interface
if it is to enclose a content entity. The HttpAsyncRequestProducer.produceContent(
ContentEncoder, IOControl) method will not be invoked if
HttpEntityEnclosingRequest.getEntity()
returns null.generateRequest in interface HttpAsyncRequestProducerpublic HttpHost getTarget()
HttpAsyncRequestProducergetTarget in interface HttpAsyncRequestProducerpublic void produceContent(ContentEncoder encoder, IOControl ioControl) throws IOException
HttpAsyncRequestProducerContentEncoder.
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 other thread
to resume output event notifications when more content is made available.
produceContent in interface HttpAsyncRequestProducerencoder - content encoder.ioControl - I/O control of the underlying connection.IOException - in case of an I/O errorpublic void requestCompleted(HttpContext context)
HttpAsyncRequestProducerrequestCompleted in interface HttpAsyncRequestProducercontext - HTTP contextpublic void failed(Exception ex)
HttpAsyncRequestProducerfailed in interface HttpAsyncRequestProducerex - exceptionpublic boolean isRepeatable()
HttpAsyncRequestProducerisRepeatable in interface HttpAsyncRequestProducerpublic void resetRequest()
throws IOException
HttpAsyncRequestProducerresetRequest in interface HttpAsyncRequestProducerIOException - in case of an I/O errorpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2005–2022 The Apache Software Foundation. All rights reserved.