Class AbstractHttpEntity
- java.lang.Object
-
- org.apache.hc.core5.http.io.entity.AbstractHttpEntity
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,EntityDetails,HttpEntity
- Direct Known Subclasses:
BasicHttpEntity,ByteArrayEntity,ByteBufferEntity,EntityTemplate,FileEntity,InputStreamEntity,PathEntity,SerializableEntity,StringEntity
public abstract class AbstractHttpEntity extends java.lang.Object implements HttpEntity
Abstract base class for mutable entities. Provides the commonly used attributes for streamed and self-contained implementations.- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description private booleanchunkedprivate java.lang.StringcontentEncodingprivate java.lang.StringcontentType(package private) static intOUTPUT_BUFFER_SIZE
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractHttpEntity(java.lang.String contentType, java.lang.String contentEncoding)protectedAbstractHttpEntity(java.lang.String contentType, java.lang.String contentEncoding, boolean chunked)protectedAbstractHttpEntity(ContentType contentType, java.lang.String contentEncoding)protectedAbstractHttpEntity(ContentType contentType, java.lang.String contentEncoding, boolean chunked)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetContentEncoding()Returns content encoding of the entity, if known.java.lang.StringgetContentType()Returns content type of the entity, if known.java.util.Set<java.lang.String>getTrailerNames()Preliminary declaration of trailing headers.Supplier<java.util.List<? extends Header>>getTrailers()Returns supplier of message trailers - headers sent after message body.booleanisChunked()Returns chunked transfer hint for this entity.booleanisRepeatable()Tells if the entity is capable of producing its data more than once.java.lang.StringtoString()voidwriteTo(java.io.OutputStream outStream)Writes the entity content out to the output stream.static voidwriteTo(HttpEntity entity, java.io.OutputStream outStream)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.hc.core5.http.EntityDetails
getContentLength
-
Methods inherited from interface org.apache.hc.core5.http.HttpEntity
getContent, isStreaming
-
-
-
-
Field Detail
-
OUTPUT_BUFFER_SIZE
static final int OUTPUT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
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)
-
AbstractHttpEntity
protected AbstractHttpEntity(ContentType contentType, java.lang.String contentEncoding, boolean chunked)
-
AbstractHttpEntity
protected AbstractHttpEntity(java.lang.String contentType, java.lang.String contentEncoding)
-
AbstractHttpEntity
protected AbstractHttpEntity(ContentType contentType, java.lang.String contentEncoding)
-
-
Method Detail
-
writeTo
public static void writeTo(HttpEntity entity, java.io.OutputStream outStream) throws java.io.IOException
- Throws:
java.io.IOException
-
writeTo
public void writeTo(java.io.OutputStream outStream) throws java.io.IOExceptionDescription copied from interface:HttpEntityWrites 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:
writeToin interfaceHttpEntity- Parameters:
outStream- the output stream to write entity content to- Throws:
java.io.IOException- if an I/O error occurs
-
getContentType
public final java.lang.String getContentType()
Description copied from interface:EntityDetailsReturns content type of the entity, if known.- Specified by:
getContentTypein interfaceEntityDetails
-
getContentEncoding
public final java.lang.String getContentEncoding()
Description copied from interface:EntityDetailsReturns content encoding of the entity, if known.- Specified by:
getContentEncodingin interfaceEntityDetails
-
isChunked
public final boolean isChunked()
Description copied from interface:EntityDetailsReturns chunked transfer hint for this entity.The behavior of wrapping entities is implementation dependent, but should respect the primary purpose.
- Specified by:
isChunkedin interfaceEntityDetails
-
isRepeatable
public boolean isRepeatable()
Description copied from interface:HttpEntityTells 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:
isRepeatablein interfaceHttpEntity- Returns:
- true if the entity is repeatable, false otherwise.
-
getTrailers
public Supplier<java.util.List<? extends Header>> getTrailers()
Description copied from interface:HttpEntityReturns supplier of message trailers - headers sent after message body. May returnnullif trailers are not available.- Specified by:
getTrailersin interfaceHttpEntity
-
getTrailerNames
public java.util.Set<java.lang.String> getTrailerNames()
Description copied from interface:EntityDetailsPreliminary declaration of trailing headers.- Specified by:
getTrailerNamesin interfaceEntityDetails
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-