Class AbstractHttpEntity

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractHttpEntity​(java.lang.String contentType, java.lang.String contentEncoding)
      Constructs a new instance with the given attributes kept as immutable.
      protected AbstractHttpEntity​(java.lang.String contentType, java.lang.String contentEncoding, boolean chunked)
      Constructs a new instance with the given attributes kept as immutable.
      protected AbstractHttpEntity​(ContentType contentType, java.lang.String contentEncoding)
      Constructs a new instance with the given attributes kept as immutable.
      protected AbstractHttpEntity​(ContentType contentType, java.lang.String contentEncoding, boolean chunked)
      Constructs a new instance with the given attributes kept as immutable.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getContentEncoding()
      Gets content encoding of this entity, if known.
      java.lang.String getContentType()
      Gets content type of this entity, if known.
      java.util.Set<java.lang.String> getTrailerNames()
      Gets the preliminary declaration of trailing headers.
      Supplier<java.util.List<? extends Header>> getTrailers()
      Gets supplier of message trailers - headers sent after message body.
      boolean isChunked()
      Tests the chunked transfer hint for this entity.
      boolean isRepeatable()
      Tests if the entity is capable of producing its data more than once.
      java.lang.String toString()  
      void writeTo​(java.io.OutputStream outStream)
      Writes this entity to an OutputStream.
      static void writeTo​(HttpEntity entity, java.io.OutputStream outStream)
      Writes an entity to an OutputStream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.io.Closeable

        close
    • Field Detail

      • contentType

        private final java.lang.String contentType
      • contentEncoding

        private final java.lang.String contentEncoding
      • chunked

        private final boolean chunked
    • Constructor Detail

      • AbstractHttpEntity

        protected AbstractHttpEntity​(java.lang.String contentType,
                                     java.lang.String contentEncoding,
                                     boolean chunked)
        Constructs a new instance with the given attributes kept as immutable.
        Parameters:
        contentType - The content-type string, may be null.
        contentEncoding - The content encoding string, may be null.
        chunked - Whether this entity should be chunked.
      • AbstractHttpEntity

        protected AbstractHttpEntity​(ContentType contentType,
                                     java.lang.String contentEncoding,
                                     boolean chunked)
        Constructs a new instance with the given attributes kept as immutable.
        Parameters:
        contentType - The content-type, may be null.
        contentEncoding - The content encoding string, may be null.
        chunked - Whether this entity should be chunked.
      • AbstractHttpEntity

        protected AbstractHttpEntity​(java.lang.String contentType,
                                     java.lang.String contentEncoding)
        Constructs a new instance with the given attributes kept as immutable.

        The new instance:

        • is not chunked.
        Parameters:
        contentType - The content-type string, may be null.
        contentEncoding - The content encoding string, may be null.
      • AbstractHttpEntity

        protected AbstractHttpEntity​(ContentType contentType,
                                     java.lang.String contentEncoding)
        Constructs a new instance with the given attributes kept as immutable.

        The new instance:

        • is not chunked.
        Parameters:
        contentType - The content-type, may be null.
        contentEncoding - The content encoding string, may be null.
    • Method Detail

      • writeTo

        public static void writeTo​(HttpEntity entity,
                                   java.io.OutputStream outStream)
                            throws java.io.IOException
        Writes an entity to an OutputStream.
        Parameters:
        entity - The entity to write, never null.
        outStream - Where to write the entity, never null.
        Throws:
        java.io.IOException - if the entity cannot generate its content stream; also thrown if the output stream is closed.
        java.lang.UnsupportedOperationException - if entity content cannot be represented as InputStream.
      • writeTo

        public void writeTo​(java.io.OutputStream outStream)
                     throws java.io.IOException
        Writes this entity to an OutputStream.
        Specified by:
        writeTo in interface HttpEntity
        Parameters:
        outStream - Where to write the entity, never null.
        Throws:
        java.io.IOException - if the entity cannot generate its content stream; also thrown if the output stream is closed.
        java.lang.UnsupportedOperationException - if entity content cannot be represented as InputStream.
      • getContentType

        public final java.lang.String getContentType()
        Description copied from interface: EntityDetails
        Gets content type of this entity, if known.
        Specified by:
        getContentType in interface EntityDetails
        Returns:
        the content type of this entity, may be null.
      • getContentEncoding

        public final java.lang.String getContentEncoding()
        Description copied from interface: EntityDetails
        Gets content encoding of this entity, if known.
        Specified by:
        getContentEncoding in interface EntityDetails
        Returns:
        the content encoding of this entity, may be null.
      • isChunked

        public final boolean isChunked()
        Tests the chunked transfer hint for this entity.

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

        This implementation always returns false.

        Specified by:
        isChunked in interface EntityDetails
        Returns:
        the chunked transfer hint for this entity.
      • isRepeatable

        public boolean isRepeatable()
        Tests 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.

        This implementation always returns false.

        Specified by:
        isRepeatable in interface HttpEntity
        Returns:
        true if the entity is repeatable, false otherwise.
      • getTrailers

        public Supplier<java.util.List<? extends Header>> getTrailers()
        Gets supplier of message trailers - headers sent after message body. May return null if trailers are not available.

        This implementation always returns null.

        Specified by:
        getTrailers in interface HttpEntity
      • getTrailerNames

        public java.util.Set<java.lang.String> getTrailerNames()
        Gets the preliminary declaration of trailing headers.

        This implementation always returns an immutable empty set.

        Specified by:
        getTrailerNames in interface EntityDetails
        Returns:
        the preliminary declaration of trailing headers.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object