Interface ResponseStream
Writable byte sink for a streaming HTTP response.
This type is intentionally not thread-safe. A stream must have one active writer at a time; applications that produce bytes from multiple threads should serialize those writes before calling this API.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionvoidflush()Hints that buffered bytes should be made available to the transport promptly.isOpen()Is this stream currently open for writes?voidWrites bytes to the response stream.voidwrite(@NonNull ByteBuffer byteBuffer) Writes the remaining bytes of a byte buffer to the response stream without mutating the caller's buffer.
-
Method Details
-
write
void write(@NonNull byte[] bytes) throws IOException, InterruptedException, StreamingResponseCanceledException Writes bytes to the response stream.Implementations copy the provided bytes before this method returns.
- Parameters:
bytes- the bytes to write- Throws:
IOException- if the bytes cannot be writtenInterruptedException- if the writer is interrupted while waiting for stream capacityStreamingResponseCanceledException- if the stream has been canceled
-
write
void write(@NonNull ByteBuffer byteBuffer) throws IOException, InterruptedException, StreamingResponseCanceledException Writes the remaining bytes of a byte buffer to the response stream without mutating the caller's buffer.Implementations copy the remaining bytes before this method returns.
- Parameters:
byteBuffer- the byte buffer to write- Throws:
IOException- if the bytes cannot be writtenInterruptedException- if the writer is interrupted while waiting for stream capacityStreamingResponseCanceledException- if the stream has been canceled
-
flush
Hints that buffered bytes should be made available to the transport promptly.Calling this method is not required for correctness. Soklet flushes any remaining bytes when the stream completes.
- Throws:
IOException- if the stream cannot be flushedInterruptedException- if the writer is interrupted while waiting for stream capacityStreamingResponseCanceledException- if the stream has been canceled
-
isOpen
-