Class ApacheHttpClient5Transport.ContentCompressingEntity

java.lang.Object
org.apache.hc.core5.http.io.entity.HttpEntityWrapper
org.opensearch.client.transport.httpclient5.ApacheHttpClient5Transport.ContentCompressingEntity
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.hc.core5.http.EntityDetails, org.apache.hc.core5.http.HttpEntity
Enclosing class:
ApacheHttpClient5Transport

public static class ApacheHttpClient5Transport.ContentCompressingEntity extends org.apache.hc.core5.http.io.entity.HttpEntityWrapper
A gzip compressing entity that also implements getContent().
  • Constructor Details

    • ContentCompressingEntity

      public ContentCompressingEntity(org.apache.hc.core5.http.HttpEntity entity)
      Creates a ApacheHttpClient5Transport.ContentCompressingEntity instance with the provided HTTP entity.
      Parameters:
      entity - the HTTP entity.
    • ContentCompressingEntity

      public ContentCompressingEntity(org.apache.hc.core5.http.HttpEntity entity, boolean chunkedEnabled)
      Creates a ApacheHttpClient5Transport.ContentCompressingEntity instance with the provided HTTP entity.
      Parameters:
      entity - the HTTP entity.
      chunkedEnabled - force enable/disable chunked transfer-encoding.
  • Method Details

    • getContentEncoding

      public String getContentEncoding()
      Returns content encoding of the entity, if known.
      Specified by:
      getContentEncoding in interface org.apache.hc.core5.http.EntityDetails
      Overrides:
      getContentEncoding in class org.apache.hc.core5.http.io.entity.HttpEntityWrapper
    • getContent

      public InputStream getContent() throws IOException
      Returns a content stream of the entity.
      Specified by:
      getContent in interface org.apache.hc.core5.http.HttpEntity
      Overrides:
      getContent in class org.apache.hc.core5.http.io.entity.HttpEntityWrapper
      Throws:
      IOException
    • isChunked

      public boolean isChunked()
      A gzip compressing entity doesn't work with chunked encoding with sigv4
      Specified by:
      isChunked in interface org.apache.hc.core5.http.EntityDetails
      Overrides:
      isChunked in class org.apache.hc.core5.http.io.entity.HttpEntityWrapper
      Returns:
      false
    • getContentLength

      public long getContentLength()
      A gzip entity requires content length in http headers.
      Specified by:
      getContentLength in interface org.apache.hc.core5.http.EntityDetails
      Overrides:
      getContentLength in class org.apache.hc.core5.http.io.entity.HttpEntityWrapper
      Returns:
      content length of gzip entity
    • writeTo

      public void writeTo(OutputStream outStream) throws IOException
      Writes the entity content out to the output stream.
      Specified by:
      writeTo in interface org.apache.hc.core5.http.HttpEntity
      Overrides:
      writeTo in class org.apache.hc.core5.http.io.entity.HttpEntityWrapper
      Parameters:
      outStream - the output stream to write entity content to
      Throws:
      IOException - if an I/O error occurs