Package org.apache.http.entity
Class AbstractHttpEntity
java.lang.Object
org.apache.http.entity.AbstractHttpEntity
- All Implemented Interfaces:
HttpEntity
- Direct Known Subclasses:
BasicHttpEntity
,ByteArrayEntity
,EntityTemplate
,FileEntity
,InputStreamEntity
,NByteArrayEntity
,NFileEntity
,NStringEntity
,SerializableEntity
,StringEntity
Abstract base class for entities.
Provides the commonly used attributes for streamed and self-contained
implementations of
HttpEntity
.- Since:
- 4.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.Obtains the Content-Encoding header.Obtains the Content-Type header.boolean
Obtains the 'chunked' flag.void
setChunked
(boolean b) Specifies the 'chunked' flag.void
setContentEncoding
(String ceString) Specifies the Content-Encoding header, as a string.void
setContentEncoding
(Header contentEncoding) Specifies the Content-Encoding header.void
setContentType
(String ctString) Specifies the Content-Type header, as a string.void
setContentType
(Header contentType) Specifies the Content-Type header.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.http.HttpEntity
getContent, getContentLength, isRepeatable, isStreaming, writeTo
-
Field Details
-
OUTPUT_BUFFER_SIZE
protected static final int OUTPUT_BUFFER_SIZEBuffer size for output stream processing.- Since:
- 4.3
- See Also:
-
contentType
-
contentEncoding
-
chunked
protected boolean chunked
-
-
Constructor Details
-
AbstractHttpEntity
protected AbstractHttpEntity()Protected default constructor. The contentType, contentEncoding and chunked attributes of the created object are set tonull
,null
andfalse
, respectively.
-
-
Method Details
-
getContentType
Obtains the Content-Type header. The default implementation returns the value of thecontentType
attribute.- Specified by:
getContentType
in interfaceHttpEntity
- Returns:
- the Content-Type header, or
null
-
getContentEncoding
Obtains the Content-Encoding header. The default implementation returns the value of thecontentEncoding
attribute.- Specified by:
getContentEncoding
in interfaceHttpEntity
- Returns:
- the Content-Encoding header, or
null
-
isChunked
public boolean isChunked()Obtains the 'chunked' flag. The default implementation returns the value of thechunked
attribute.- Specified by:
isChunked
in interfaceHttpEntity
- Returns:
- the 'chunked' flag
-
setContentType
Specifies the Content-Type header. The default implementation sets the value of thecontentType
attribute.- Parameters:
contentType
- the new Content-Type header, ornull
to unset
-
setContentType
Specifies the Content-Type header, as a string. The default implementation callssetContentType(Header)
.- Parameters:
ctString
- the new Content-Type header, ornull
to unset
-
setContentEncoding
Specifies the Content-Encoding header. The default implementation sets the value of thecontentEncoding
attribute.- Parameters:
contentEncoding
- the new Content-Encoding header, ornull
to unset
-
setContentEncoding
Specifies the Content-Encoding header, as a string. The default implementation callssetContentEncoding(Header)
.- Parameters:
ceString
- the new Content-Encoding header, ornull
to unset
-
setChunked
public void setChunked(boolean b) Specifies the 'chunked' flag.Note that the chunked setting is a hint only. If using HTTP/1.0, chunking is never performed. Otherwise, even if chunked is false, HttpClient must use chunk coding if the entity content length is unknown (-1).
The default implementation sets the value of the
chunked
attribute.- Parameters:
b
- the new 'chunked' flag
-
consumeContent
Deprecated.(4.1) Either useHttpEntity.getContent()
and callInputStream.close()
on that; otherwise callHttpEntity.writeTo(java.io.OutputStream)
which is required to free the resources.The default implementation does not consume anything.- Specified by:
consumeContent
in interfaceHttpEntity
- Throws:
IOException
- if an I/O error occurs.- See Also:
-
toString
-
HttpEntity.getContent()
and callInputStream.close()
on that; otherwise callHttpEntity.writeTo(java.io.OutputStream)
which is required to free the resources.