Class AbstractHttpEntity

java.lang.Object
org.apache.hc.core5.http.io.entity.AbstractHttpEntity
All Implemented Interfaces:
Closeable, AutoCloseable, EntityDetails, HttpEntity
Direct Known Subclasses:
BasicHttpEntity, ByteArrayEntity, ByteBufferEntity, EntityTemplate, FileEntity, InputStreamEntity, PathEntity, SerializableEntity, StringEntity

public abstract class AbstractHttpEntity extends Object implements HttpEntity
Abstract base class for mutable entities. Provides the commonly used attributes for streamed and self-contained implementations.
Since:
4.0
  • Field Details

    • OUTPUT_BUFFER_SIZE

      static final int OUTPUT_BUFFER_SIZE
      See Also:
    • contentType

      private final String contentType
    • contentEncoding

      private final String contentEncoding
    • chunked

      private final boolean chunked
  • Constructor Details

    • AbstractHttpEntity

      protected AbstractHttpEntity(String contentType, String contentEncoding, boolean chunked)
    • AbstractHttpEntity

      protected AbstractHttpEntity(ContentType contentType, String contentEncoding, boolean chunked)
    • AbstractHttpEntity

      protected AbstractHttpEntity(String contentType, String contentEncoding)
    • AbstractHttpEntity

      protected AbstractHttpEntity(ContentType contentType, String contentEncoding)
  • Method Details

    • writeTo

      public static void writeTo(HttpEntity entity, OutputStream outStream) throws IOException
      Throws:
      IOException
    • writeTo

      public void writeTo(OutputStream outStream) throws IOException
      Description copied from interface: HttpEntity
      Writes the entity content out to the output stream.

      IMPORTANT: Please note all entity implementations must ensure that all allocated resources are properly deallocated when this method returns.

      Specified by:
      writeTo in interface HttpEntity
      Parameters:
      outStream - the output stream to write entity content to
      Throws:
      IOException - if an I/O error occurs
    • getContentType

      public final String getContentType()
      Description copied from interface: EntityDetails
      Returns content type of the entity, if known.
      Specified by:
      getContentType in interface EntityDetails
    • getContentEncoding

      public final String getContentEncoding()
      Description copied from interface: EntityDetails
      Returns content encoding of the entity, if known.
      Specified by:
      getContentEncoding in interface EntityDetails
    • isChunked

      public final boolean isChunked()
      Description copied from interface: EntityDetails
      Returns chunked transfer hint for this entity.

      The behavior of wrapping entities is implementation dependent, but should respect the primary purpose.

      Specified by:
      isChunked in interface EntityDetails
    • isRepeatable

      public boolean isRepeatable()
      Description copied from interface: HttpEntity
      Tells if the entity is capable of producing its data more than once. A repeatable entity's getContent() and writeTo(OutputStream) methods can be called more than once whereas a non-repeatable entity's can not.
      Specified by:
      isRepeatable in interface HttpEntity
      Returns:
      true if the entity is repeatable, false otherwise.
    • getTrailers

      public Supplier<List<? extends Header>> getTrailers()
      Description copied from interface: HttpEntity
      Returns supplier of message trailers - headers sent after message body. May return null if trailers are not available.
      Specified by:
      getTrailers in interface HttpEntity
    • getTrailerNames

      public Set<String> getTrailerNames()
      Description copied from interface: EntityDetails
      Preliminary declaration of trailing headers.
      Specified by:
      getTrailerNames in interface EntityDetails
    • toString

      public String toString()
      Overrides:
      toString in class Object