Package com.azure.core.http.rest
Class StreamResponse
- All Implemented Interfaces:
Response<Flux<ByteBuffer>>,Closeable,AutoCloseable
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
ConstructorsConstructorDescriptionStreamResponse(HttpRequest request, int statusCode, HttpHeaders headers, Flux<ByteBuffer> value) Deprecated.StreamResponse(HttpResponse response) Creates aStreamResponse. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Disposes the connection associated with thisStreamResponse.getValue()The content of the HTTP response as a stream ofbyte buffers.voidwriteValueTo(WritableByteChannel channel) Transfers content bytes to theWritableByteChannel.writeValueToAsync(AsynchronousByteChannel channel) Transfers content bytes to theAsynchronousByteChannel.Methods inherited from class com.azure.core.http.rest.SimpleResponse
getHeaders, getRequest, getStatusCode
-
Constructor Details
-
StreamResponse
@Deprecated public StreamResponse(HttpRequest request, int statusCode, HttpHeaders headers, Flux<ByteBuffer> value) Deprecated.Creates aStreamResponse.- 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
Creates aStreamResponse.- Parameters:
response- The HTTP response.
-
-
Method Details
-
getValue
The content of the HTTP response as a stream ofbyte buffers.- Specified by:
getValuein interfaceResponse<Flux<ByteBuffer>>- Overrides:
getValuein classSimpleResponse<Flux<ByteBuffer>>- Returns:
- The content of the HTTP response as a stream of
byte buffers.
-
writeValueToAsync
Transfers content bytes to theAsynchronousByteChannel.- Parameters:
channel- The destinationAsynchronousByteChannel.- Returns:
- A
Monothat completes when transfer is completed.
-
writeValueTo
Transfers content bytes to theWritableByteChannel.- Parameters:
channel- The destinationWritableByteChannel.- Throws:
UncheckedIOException- When I/O operation fails.
-
close
public void close()Disposes the connection associated with thisStreamResponse.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
StreamResponse(HttpResponse)