Class ChunkedOutputStream

java.lang.Object
java.io.OutputStream
org.apache.hc.core5.http.impl.io.ChunkedOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class ChunkedOutputStream extends OutputStream
Implements chunked transfer coding. The content is sent in small chunks. Entities transferred using this output stream can be of unlimited length. Writes are buffered to an internal buffer (2048 default size).

Note that this class NEVER closes the underlying stream, even when close() gets called. Instead, the stream will be marked as closed and no further output will be permitted.

Since:
4.0
  • Constructor Details

    • ChunkedOutputStream

      public ChunkedOutputStream(SessionOutputBuffer buffer, OutputStream outputStream, byte[] chunkCache, Supplier<List<? extends Header>> trailerSupplier)
      Default constructor.
      Parameters:
      buffer - Session output buffer
      outputStream - Output stream
      chunkCache - Buffer used to aggregate smaller writes into chunks.
      trailerSupplier - Trailer supplier. May be null
      Since:
      5.1
    • ChunkedOutputStream

      public ChunkedOutputStream(SessionOutputBuffer buffer, OutputStream outputStream, int chunkSizeHint, Supplier<List<? extends Header>> trailerSupplier)
      Constructor taking an integer chunk size hint.
      Parameters:
      buffer - Session output buffer
      outputStream - Output stream
      chunkSizeHint - minimal chunk size hint
      trailerSupplier - Trailer supplier. May be null
      Since:
      5.0
    • ChunkedOutputStream

      public ChunkedOutputStream(SessionOutputBuffer buffer, OutputStream outputStream, int chunkSizeHint)
      Constructor with no trailers.
      Parameters:
      buffer - Session output buffer
      outputStream - Output stream
      chunkSizeHint - minimal chunk size hint
  • Method Details