Top Description Fields Constructors Methods
org.apache.hc.core5.http.nio.support

public Class BasicResponseProducer

extends Object
implements AsyncResponseProducer
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.nio.AsyncResponseProducer, org.apache.hc.core5.http.nio.AsyncDataProducer, org.apache.hc.core5.http.nio.ResourceHolder
Imports
java.io.IOException, org.apache.hc.core5.http.ContentType, .HttpException, .HttpResponse, .HttpStatus, org.apache.hc.core5.http.message.BasicHttpResponse, org.apache.hc.core5.http.nio.AsyncEntityProducer, .AsyncResponseProducer, .DataStreamChannel, .ResponseChannel, org.apache.hc.core5.http.nio.entity.AsyncEntityProducers, org.apache.hc.core5.http.protocol.HttpContext, org.apache.hc.core5.util.Args

Basic implementation of AsyncResponseProducer that produces one fixed response and relies on a AsyncEntityProducer to generate response entity stream.
Since
5.0

Field Summary

Modifier and TypeField and Description
private final AsyncEntityProducer
private final HttpResponse

Constructor Summary

AccessConstructor and Description
public
BasicResponseProducer(final HttpResponse response, final AsyncEntityProducer dataProducer)

public
public
BasicResponseProducer(final int code, final AsyncEntityProducer dataProducer)

public
BasicResponseProducer(final HttpResponse response, final String message, final ContentType contentType)

public
BasicResponseProducer(final HttpResponse response, final String message)

public
BasicResponseProducer(final int code, final String message, final ContentType contentType)

public
BasicResponseProducer(final int code, final String message)

public

Method Summary

Modifier and TypeMethod and Description
public int
available()

Implements org.apache.hc.core5.http.nio.AsyncDataProducer.available.

Returns the number of bytes immediately available for output.
public void
failed(final Exception
the cause of the failure.
cause
)

Implements org.apache.hc.core5.http.nio.AsyncResponseProducer.failed.

Triggered to signal a failure in data generation.
public void
produce(final DataStreamChannel
the data channel capable to accepting more data.
channel
)

Implements org.apache.hc.core5.http.nio.AsyncDataProducer.produce.

Triggered to signal the ability of the underlying data channel to accept more data.
public void
public void
sendResponse(final ResponseChannel
the response channel capable to accepting response messages.
responseChannel
,
final HttpContext
the actual execution context.
httpContext
)

Implements org.apache.hc.core5.http.nio.AsyncResponseProducer.sendResponse.

Triggered to signal the ability of the underlying response channel to accept response messages.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dataProducerback to summary
private final AsyncEntityProducer dataProducer
responseback to summary
private final HttpResponse response

Constructor Detail

BasicResponseProducerback to summary
public BasicResponseProducer(final HttpResponse response, final AsyncEntityProducer dataProducer)
BasicResponseProducerback to summary
public BasicResponseProducer(final HttpResponse response)
BasicResponseProducerback to summary
public BasicResponseProducer(final int code, final AsyncEntityProducer dataProducer)
BasicResponseProducerback to summary
public BasicResponseProducer(final HttpResponse response, final String message, final ContentType contentType)
BasicResponseProducerback to summary
public BasicResponseProducer(final HttpResponse response, final String message)
BasicResponseProducerback to summary
public BasicResponseProducer(final int code, final String message, final ContentType contentType)
BasicResponseProducerback to summary
public BasicResponseProducer(final int code, final String message)
BasicResponseProducerback to summary
public BasicResponseProducer(final AsyncEntityProducer dataProducer)

Method Detail

availableback to summary
public int available()

Implements org.apache.hc.core5.http.nio.AsyncDataProducer.available.

Doc from org.apache.hc.core5.http.nio.AsyncDataProducer.available.

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.

Returns:int

the number of bytes immediately available for output

Annotations
@Override
failedback to summary
public void failed(final Exception cause)

Implements org.apache.hc.core5.http.nio.AsyncResponseProducer.failed.

Doc from org.apache.hc.core5.http.nio.AsyncResponseProducer.failed.

Triggered to signal a failure in data generation.

Parameters
cause:Exception

the cause of the failure.

Annotations
@Override
produceback to summary
public void produce(final DataStreamChannel channel) throws IOException

Implements org.apache.hc.core5.http.nio.AsyncDataProducer.produce.

Doc from org.apache.hc.core5.http.nio.AsyncDataProducer.produce.

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.

Parameters
channel:DataStreamChannel

the data channel capable to accepting more data.

Annotations
@Override
releaseResourcesback to summary
public void releaseResources()

Implements org.apache.hc.core5.http.nio.ResourceHolder.releaseResources.

Annotations
@Override
sendResponseback to summary
public void sendResponse(final ResponseChannel responseChannel, final HttpContext httpContext) throws HttpException, IOException

Implements org.apache.hc.core5.http.nio.AsyncResponseProducer.sendResponse.

Doc from org.apache.hc.core5.http.nio.AsyncResponseProducer.sendResponse.

Triggered to signal the ability of the underlying response channel to accept response messages. The data producer can choose to send response messages immediately inside the call or asynchronously at some later point.

Parameters
responseChannel:ResponseChannel

the response channel capable to accepting response messages.

httpContext:HttpContext

the actual execution context.

Annotations
@Override