Class BasicRequestProducer
- java.lang.Object
-
- org.apache.hc.core5.http.nio.support.BasicRequestProducer
-
- All Implemented Interfaces:
AsyncDataProducer
,AsyncRequestProducer
,ResourceHolder
public class BasicRequestProducer extends java.lang.Object implements AsyncRequestProducer
Basic implementation ofAsyncRequestProducer
that produces one fixed request and relies on aAsyncEntityProducer
to generate request entity stream.- Since:
- 5.0
-
-
Field Summary
Fields Modifier and Type Field Description private AsyncEntityProducer
dataProducer
private HttpRequest
request
-
Constructor Summary
Constructors Constructor Description BasicRequestProducer(java.lang.String method, java.net.URI requestUri)
BasicRequestProducer(java.lang.String method, java.net.URI requestUri, AsyncEntityProducer dataProducer)
BasicRequestProducer(java.lang.String method, HttpHost host, java.lang.String path)
BasicRequestProducer(java.lang.String method, HttpHost host, java.lang.String path, AsyncEntityProducer dataProducer)
BasicRequestProducer(HttpRequest request, AsyncEntityProducer dataProducer)
BasicRequestProducer(Method method, java.net.URI requestUri)
BasicRequestProducer(Method method, java.net.URI requestUri, AsyncEntityProducer dataProducer)
BasicRequestProducer(Method method, HttpHost host, java.lang.String path)
BasicRequestProducer(Method method, HttpHost host, java.lang.String path, AsyncEntityProducer dataProducer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
Returns the number of bytes immediately available for output.void
failed(java.lang.Exception cause)
Triggered to signal a failure in data generation.boolean
isRepeatable()
Determines whether the producer can consistently produce the same content after invocation ofResourceHolder.releaseResources()
.void
produce(DataStreamChannel channel)
Triggered to signal the ability of the underlying data channel to accept more data.void
releaseResources()
void
sendRequest(RequestChannel requestChannel, HttpContext httpContext)
Triggered to signal the ability of the underlying request channel to accept a request messages.
-
-
-
Field Detail
-
request
private final HttpRequest request
-
dataProducer
private final AsyncEntityProducer dataProducer
-
-
Constructor Detail
-
BasicRequestProducer
public BasicRequestProducer(HttpRequest request, AsyncEntityProducer dataProducer)
-
BasicRequestProducer
public BasicRequestProducer(java.lang.String method, HttpHost host, java.lang.String path, AsyncEntityProducer dataProducer)
-
BasicRequestProducer
public BasicRequestProducer(java.lang.String method, HttpHost host, java.lang.String path)
-
BasicRequestProducer
public BasicRequestProducer(java.lang.String method, java.net.URI requestUri, AsyncEntityProducer dataProducer)
-
BasicRequestProducer
public BasicRequestProducer(java.lang.String method, java.net.URI requestUri)
-
BasicRequestProducer
public BasicRequestProducer(Method method, HttpHost host, java.lang.String path, AsyncEntityProducer dataProducer)
-
BasicRequestProducer
public BasicRequestProducer(Method method, HttpHost host, java.lang.String path)
-
BasicRequestProducer
public BasicRequestProducer(Method method, java.net.URI requestUri, AsyncEntityProducer dataProducer)
-
BasicRequestProducer
public BasicRequestProducer(Method method, java.net.URI requestUri)
-
-
Method Detail
-
sendRequest
public void sendRequest(RequestChannel requestChannel, HttpContext httpContext) throws HttpException, java.io.IOException
Description copied from interface:AsyncRequestProducer
Triggered to signal the ability of the underlying request channel to accept a request messages. The data producer can choose to send a request message immediately inside the call or asynchronously at some later point.- Specified by:
sendRequest
in interfaceAsyncRequestProducer
- Parameters:
requestChannel
- the request channel capable to accepting a request message.httpContext
- the actual execution context.- Throws:
HttpException
java.io.IOException
-
available
public int available()
Description copied from interface:AsyncDataProducer
Returns the number of bytes immediately available for output. This method can be used as a hint to control output events of the underlying I/O session.- Specified by:
available
in interfaceAsyncDataProducer
- Returns:
- the number of bytes immediately available for output
-
produce
public void produce(DataStreamChannel channel) throws java.io.IOException
Description copied from interface:AsyncDataProducer
Triggered to signal the ability of the underlying data channel to accept more data. The data producer can choose to write data immediately inside the call or asynchronously at some later point.- Specified by:
produce
in interfaceAsyncDataProducer
- Parameters:
channel
- the data channel capable to accepting more data.- Throws:
java.io.IOException
-
isRepeatable
public boolean isRepeatable()
Description copied from interface:AsyncRequestProducer
Determines whether the producer can consistently produce the same content after invocation ofResourceHolder.releaseResources()
.- Specified by:
isRepeatable
in interfaceAsyncRequestProducer
-
failed
public void failed(java.lang.Exception cause)
Description copied from interface:AsyncRequestProducer
Triggered to signal a failure in data generation.- Specified by:
failed
in interfaceAsyncRequestProducer
- Parameters:
cause
- the cause of the failure.
-
releaseResources
public void releaseResources()
- Specified by:
releaseResources
in interfaceResourceHolder
-
-