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
public abstract class AbstractHttpEntity extends java.lang.Object implements HttpEntity
Abstract base class for entities. Provides the commonly used attributes for streamed and self-contained implementations ofHttpEntity.- Since:
- 4.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidconsumeContent()Deprecated.(4.1) Either useHttpEntity.getContent()and callInputStream.close()on that; otherwise callHttpEntity.writeTo(java.io.OutputStream)which is required to free the resources.HeadergetContentEncoding()Obtains the Content-Encoding header.HeadergetContentType()Obtains the Content-Type header.booleanisChunked()Obtains the 'chunked' flag.voidsetChunked(boolean b)Specifies the 'chunked' flag.voidsetContentEncoding(java.lang.String ceString)Specifies the Content-Encoding header, as a string.voidsetContentEncoding(Header contentEncoding)Specifies the Content-Encoding header.voidsetContentType(java.lang.String ctString)Specifies the Content-Type header, as a string.voidsetContentType(Header contentType)Specifies the Content-Type header.java.lang.StringtoString()-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.http.HttpEntity
getContent, getContentLength, isRepeatable, isStreaming, writeTo
-
-
-
-
Method Detail
-
getContentType
public Header getContentType()
Obtains the Content-Type header. The default implementation returns the value of thecontentTypeattribute.- Specified by:
getContentTypein interfaceHttpEntity- Returns:
- the Content-Type header, or
null
-
getContentEncoding
public Header getContentEncoding()
Obtains the Content-Encoding header. The default implementation returns the value of thecontentEncodingattribute.- Specified by:
getContentEncodingin interfaceHttpEntity- Returns:
- the Content-Encoding header, or
null
-
isChunked
public boolean isChunked()
Obtains the 'chunked' flag. The default implementation returns the value of thechunkedattribute.- Specified by:
isChunkedin interfaceHttpEntity- Returns:
- the 'chunked' flag
-
setContentType
public void setContentType(Header contentType)
Specifies the Content-Type header. The default implementation sets the value of thecontentTypeattribute.- Parameters:
contentType- the new Content-Type header, ornullto unset
-
setContentType
public void setContentType(java.lang.String ctString)
Specifies the Content-Type header, as a string. The default implementation callssetContentType(Header).- Parameters:
ctString- the new Content-Type header, ornullto unset
-
setContentEncoding
public void setContentEncoding(Header contentEncoding)
Specifies the Content-Encoding header. The default implementation sets the value of thecontentEncodingattribute.- Parameters:
contentEncoding- the new Content-Encoding header, ornullto unset
-
setContentEncoding
public void setContentEncoding(java.lang.String ceString)
Specifies the Content-Encoding header, as a string. The default implementation callssetContentEncoding(Header).- Parameters:
ceString- the new Content-Encoding header, ornullto 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
chunkedattribute.- Parameters:
b- the new 'chunked' flag
-
consumeContent
@Deprecated public void consumeContent() throws java.io.IOExceptionDeprecated.(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:
consumeContentin interfaceHttpEntity- Throws:
java.io.IOException- if an I/O error occurs.- See Also:
and #writeTo(OutputStream)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-