StreamResponse Class

Implements

public final class StreamResponse
extends SimpleResponse<reactor.core.publisher.Flux<ByteBuffer>>
implements Closeable

This class represents a REST response with a streaming content. It encapsulates the HTTP request that resulted in the response, the status code of the HTTP response, the headers of the HTTP response, and the content of the HTTP response as a stream of byte buffers.

It also provides methods to write the content of the HTTP response to a AsynchronousByteChannel or a WritableByteChannel, and to dispose the connection associated with the response.

Constructor Summary

Constructor Description
StreamResponse(HttpRequest request, int statusCode, HttpHeaders headers, Flux<ByteBuffer> value)

Deprecated

Creates a StreamResponse.

StreamResponse(HttpResponse response)

Creates a StreamResponse.

Method Summary

Modifier and Type Method and Description
void close()

Disposes the connection associated with this StreamResponse.

reactor.core.publisher.Flux<ByteBuffer> getValue()

The content of the HTTP response as a stream of byte buffers.

void writeValueTo(WritableByteChannel channel)

Transfers content bytes to the WritableByteChannel.

reactor.core.publisher.Mono<Void> writeValueToAsync(AsynchronousByteChannel channel)

Transfers content bytes to the AsynchronousByteChannel.

Methods inherited from SimpleResponse

Methods inherited from java.lang.Object

Constructor Details

StreamResponse

@Deprecated
public StreamResponse(HttpRequest request, int statusCode, HttpHeaders headers, Flux<ByteBuffer> value)

Deprecated

Creates a StreamResponse.

Parameters:

request - The request which resulted in this response.
statusCode - The status code of the HTTP response.
headers - The headers of the HTTP response.
value - The content of the HTTP response.

StreamResponse

public StreamResponse(HttpResponse response)

Creates a StreamResponse.

Parameters:

response - The HTTP response.

Method Details

close

public void close()

Disposes the connection associated with this StreamResponse.

getValue

public Flux<ByteBuffer> getValue()

The content of the HTTP response as a stream of byte buffers.

Overrides:

StreamResponse.getValue()

Returns:

The content of the HTTP response as a stream of byte buffers.

writeValueTo

public void writeValueTo(WritableByteChannel channel)

Transfers content bytes to the WritableByteChannel.

Parameters:

channel - The destination WritableByteChannel.

writeValueToAsync

public Mono<Void> writeValueToAsync(AsynchronousByteChannel channel)

Transfers content bytes to the AsynchronousByteChannel.

Parameters:

channel - The destination AsynchronousByteChannel.

Returns:

A Mono that completes when transfer is completed.

Applies to