public class GzipHttpEntity extends Object implements HttpEntityWrapper
The body of this entity will be the body of the origin entity compressed in gzip format.
If the origin entity has ETag, this entity will append ".gzip" to it.
This entity is sharable iff the origin entity is sharable.
If this entity is sharable and to be served to multiple http messages, consider the
CachedHttpEntity
wrapper.
Constructor and Description |
---|
GzipHttpEntity(HttpEntity origin,
int compressionLevel)
Create a GzipHttpEntity, which compresses the origin entity body with gzip.
|
Instance Methods | |
---|---|
HttpEntity |
getOriginEntity()
The origin entity.
|
ByteSource |
body()
The body after compression.
|
Long |
contentLength()
The length of the body (after compression).
|
String |
contentEncoding()
The content encoding, containing "gzip".
|
String |
etag()
The ETag.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
contentType, etagIsWeak, expires, lastModified
bodyBytes, bodyString
public GzipHttpEntity(HttpEntity origin, int compressionLevel)
`compressionLevel` can be 0-9. For on-the-fly gzip, consider compressionLevel=1, which is faster, with pretty good compression ratio.
public HttpEntity getOriginEntity()
getOriginEntity
in interface HttpEntityWrapper
public ByteSource body()
The body of this entity will be the body of the origin entity compressed in gzip format.
See also GzipByteSource
.
body
in interface HttpEntity
body
in interface HttpEntityWrapper
public Long contentLength()
This implementation usually returns null, because the length is unknown without actually performing the compression.
contentLength
in interface HttpEntity
contentLength
in interface HttpEntityWrapper
public String contentEncoding()
If the origin entity has no content encoding, this method returns "gzip".
If the origin entity has a content encoding, this method appends ", gzip" to it.
contentEncoding
in interface HttpEntity
contentEncoding
in interface HttpEntityWrapper
public String etag()
If the origin entity has no ETag, this method returns null.
If the origin entity has an ETag, this method appends ".gzip" to it.
etag
in interface HttpEntity
etag
in interface HttpEntityWrapper