public class CachedHttpEntity extends Object implements HttpEntity
The body and metadata of the origin entity are cached in memory. This is useful for frequently requested entities.
This entity is always sharable, whether the origin entity is sharable or not.
Constructor and Description |
---|
CachedHttpEntity(HttpEntity origin)
Create a cache of the origin entity.
|
Instance Methods | |
---|---|
ByteSource |
body()
The entity body.
|
ContentType |
contentType()
Return
"contentType" of the origin entity. |
Long |
contentLength()
The length of the body.
|
String |
contentEncoding()
Return
"contentEncoding" of the origin entity. |
Instant |
lastModified()
Return
"lastModified" of the origin entity. |
Instant |
expires()
Return
"expires" of the origin entity. |
String |
etag()
Return
"etag" of the origin entity. |
boolean |
etagIsWeak()
Return
"etagIsWeak" of the origin entity. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
bodyBytes, bodyString
public CachedHttpEntity(HttpEntity origin)
public ByteSource body()
The returned ByteSource is based on an in-memory cache of the origin entity body.
See ByteSourceCache
.
This entity is sharable, the body() method can be called multiple times.
body
in interface HttpEntity
public ContentType contentType()
"contentType"
of the origin entity.contentType
in interface HttpEntity
public Long contentLength()
The length may be null/unknown initially;
however, it eventually becomes known after caching is done.
See ByteSourceCache.getTotalBytes()
.
contentLength
in interface HttpEntity
public String contentEncoding()
"contentEncoding"
of the origin entity.contentEncoding
in interface HttpEntity
public Instant lastModified()
"lastModified"
of the origin entity.lastModified
in interface HttpEntity
public Instant expires()
"expires"
of the origin entity.expires
in interface HttpEntity
public String etag()
"etag"
of the origin entity.etag
in interface HttpEntity
public boolean etagIsWeak()
"etagIsWeak"
of the origin entity.etagIsWeak
in interface HttpEntity