Class DecompressingEntity

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, org.apache.hc.core5.http.EntityDetails, org.apache.hc.core5.http.HttpEntity

    public class DecompressingEntity
    extends org.apache.hc.core5.http.io.entity.HttpEntityWrapper
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int BUF_SIZE  
      private java.io.InputStream cached  
      private org.apache.hc.core5.io.IOFunction<java.io.InputStream,​java.io.InputStream> decoder  
    • Constructor Summary

      Constructors 
      Constructor Description
      DecompressingEntity​(org.apache.hc.core5.http.HttpEntity src, org.apache.hc.core5.io.IOFunction<java.io.InputStream,​java.io.InputStream> decoder)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.io.InputStream getContent()
      Returns the cached decoded stream, creating it once if necessary.
      java.lang.String getContentEncoding()
      Content is no longer encoded
      long getContentLength()
      Length is unknown after decompression.
      private java.io.InputStream getDecompressingStream()  
      void writeTo​(java.io.OutputStream out)
      Streams the decoded bytes directly to out.
      • Methods inherited from class org.apache.hc.core5.http.io.entity.HttpEntityWrapper

        close, getContentType, getTrailerNames, getTrailers, isChunked, isRepeatable, isStreaming, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • decoder

        private final org.apache.hc.core5.io.IOFunction<java.io.InputStream,​java.io.InputStream> decoder
      • cached

        private volatile java.io.InputStream cached
    • Constructor Detail

      • DecompressingEntity

        public DecompressingEntity​(org.apache.hc.core5.http.HttpEntity src,
                                   org.apache.hc.core5.io.IOFunction<java.io.InputStream,​java.io.InputStream> decoder)
    • Method Detail

      • getDecompressingStream

        private java.io.InputStream getDecompressingStream()
                                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • getContent

        public java.io.InputStream getContent()
                                       throws java.io.IOException
        Returns the cached decoded stream, creating it once if necessary.
        Specified by:
        getContent in interface org.apache.hc.core5.http.HttpEntity
        Overrides:
        getContent in class org.apache.hc.core5.http.io.entity.HttpEntityWrapper
        Throws:
        java.io.IOException
      • getContentLength

        public long getContentLength()
        Length is unknown after decompression.
        Specified by:
        getContentLength in interface org.apache.hc.core5.http.EntityDetails
        Overrides:
        getContentLength in class org.apache.hc.core5.http.io.entity.HttpEntityWrapper
      • getContentEncoding

        public java.lang.String getContentEncoding()
        Content is no longer encoded
        Specified by:
        getContentEncoding in interface org.apache.hc.core5.http.EntityDetails
        Overrides:
        getContentEncoding in class org.apache.hc.core5.http.io.entity.HttpEntityWrapper
      • writeTo

        public void writeTo​(java.io.OutputStream out)
                     throws java.io.IOException
        Streams the decoded bytes directly to out.
        Specified by:
        writeTo in interface org.apache.hc.core5.http.HttpEntity
        Overrides:
        writeTo in class org.apache.hc.core5.http.io.entity.HttpEntityWrapper
        Throws:
        java.io.IOException