org.apache.hc.core5.http.impl.nio

## Class ChunkEncoder

- java.lang.Object
- - org.apache.hc.core5.http.impl.nio.AbstractContentEncoder
  - - org.apache.hc.core5.http.impl.nio.ChunkEncoder

- All Implemented Interfaces:
    ContentEncoder

      public class ChunkEncoder
      extends AbstractContentEncoder

  Implements chunked transfer coding. The content is sent in small chunks. Entities transferred using this decoder can be of unlimited length.
  Since:
    4.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ChunkEncoder(WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics)`
    `ChunkEncoder(WritableByteChannel channel, SessionOutputBuffer buffer, BasicHttpTransportMetrics metrics, int chunkSizeHint)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `complete(List<? extends Header> trailers)` Terminates the content stream.
    `String` | `toString()`
    `int` | `write(ByteBuffer src)` Writes a portion of entity content to the underlying channel.

    - ### Methods inherited from class org.apache.hc.core5.http.impl.nio.AbstractContentEncoder

      `assertNotCompleted, buffer, channel, complete, flushToChannel, isCompleted, metrics, writeToBuffer, writeToChannel, writeToChannel`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ChunkEncoder

          public ChunkEncoder(WritableByteChannel channel,
                              SessionOutputBuffer buffer,
                              BasicHttpTransportMetrics metrics,
                              int chunkSizeHint)

      Parameters:
        `channel` - underlying channel.
        `buffer` - session buffer.
        `metrics` - transport metrics.
      Since:
        5.0

    - #### ChunkEncoder

          public ChunkEncoder(WritableByteChannel channel,
                              SessionOutputBuffer buffer,
                              BasicHttpTransportMetrics metrics)

  - ### Method Detail

    - #### write

          public int write(ByteBuffer src)
                    throws IOException

      Description copied from interface: `ContentEncoder`
      Writes a portion of entity content to the underlying channel.
      Parameters:
        `src` - The buffer from which content is to be retrieved
      Returns:
        The number of bytes read, possibly zero
      Throws:
        `IOException` - if I/O error occurs while writing content

    - #### complete

          public void complete(List<? extends Header> trailers)
                        throws IOException

      Description copied from interface: `ContentEncoder`
      Terminates the content stream.
      Specified by:
        `complete` in interface `ContentEncoder`
      Overrides:
        `complete` in class `AbstractContentEncoder`
      Throws:
        `IOException` - if I/O error occurs while writing content

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2005–2022 The Apache Software Foundation. All rights reserved.