Class DeflatingAsyncEntityProducer

java.lang.Object
org.apache.hc.client5.http.async.methods.DeflatingAsyncEntityProducer
All Implemented Interfaces:
org.apache.hc.core5.http.EntityDetails, org.apache.hc.core5.http.nio.AsyncDataProducer, org.apache.hc.core5.http.nio.AsyncEntityProducer, org.apache.hc.core5.http.nio.ResourceHolder

public final class DeflatingAsyncEntityProducer extends Object implements org.apache.hc.core5.http.nio.AsyncEntityProducer
AsyncEntityProducer that streams the output of another producer through the raw DEFLATE compression algorithm.

The delegate’s bytes are read in small chunks, compressed with Deflater and written immediately to the HTTP I/O layer. Memory use is therefore bounded even for very large request entities.

Since:
5.6
  • Field Details

    • IN_BUF

      private static final int IN_BUF
      inbound copy‐buffer
      See Also:
    • OUT_BUF

      private static final int OUT_BUF
      outbound staging buffer
      See Also:
    • delegate

      private final org.apache.hc.core5.http.nio.AsyncEntityProducer delegate
    • contentType

      private final String contentType
    • deflater

      private final Deflater deflater
    • pending

      private final ByteBuffer pending
      holds compressed bytes not yet sent downstream
    • in

      private final byte[] in
    • delegateEnded

      private final AtomicBoolean delegateEnded
    • finished

      private boolean finished
  • Constructor Details

    • DeflatingAsyncEntityProducer

      public DeflatingAsyncEntityProducer(org.apache.hc.core5.http.nio.AsyncEntityProducer delegate)
  • Method Details

    • isRepeatable

      public boolean isRepeatable()
      Specified by:
      isRepeatable in interface org.apache.hc.core5.http.nio.AsyncEntityProducer
    • getContentLength

      public long getContentLength()
      Specified by:
      getContentLength in interface org.apache.hc.core5.http.EntityDetails
    • getContentType

      public String getContentType()
      Specified by:
      getContentType in interface org.apache.hc.core5.http.EntityDetails
    • getContentEncoding

      public String getContentEncoding()
      Specified by:
      getContentEncoding in interface org.apache.hc.core5.http.EntityDetails
    • isChunked

      public boolean isChunked()
      Specified by:
      isChunked in interface org.apache.hc.core5.http.EntityDetails
    • getTrailerNames

      public Set<String> getTrailerNames()
      Specified by:
      getTrailerNames in interface org.apache.hc.core5.http.EntityDetails
    • available

      public int available()
      Specified by:
      available in interface org.apache.hc.core5.http.nio.AsyncDataProducer
    • produce

      public void produce(org.apache.hc.core5.http.nio.DataStreamChannel channel) throws IOException
      Specified by:
      produce in interface org.apache.hc.core5.http.nio.AsyncDataProducer
      Throws:
      IOException
    • flushPending

      private boolean flushPending(org.apache.hc.core5.http.nio.DataStreamChannel ch) throws IOException
      copy as much as possible from pending to the wire
      Throws:
      IOException
    • deflateToPending

      private void deflateToPending()
      drain deflater into pending
    • failed

      public void failed(Exception cause)
      Specified by:
      failed in interface org.apache.hc.core5.http.nio.AsyncEntityProducer
    • releaseResources

      public void releaseResources()
      Specified by:
      releaseResources in interface org.apache.hc.core5.http.nio.ResourceHolder