public class TextHttpEntity extends Object implements HttpEntity
The entity body is a sequence of bytes encoding the texts, using the charset specified in the content type.
This entity is usually for "text/*"
content types, but may also be used for
other types like "application/javascript"
.
This is a sharable entity.
If this entity is to be served to multiple http messages, consider the
CachedHttpEntity
wrapper.
Constructor and Description |
---|
TextHttpEntity(TextDoc doc)
Create a TextHttpEntity over the TextDoc.
|
TextHttpEntity(ContentType contentType,
Stream<? extends CharSequence> texts)
Create a TextHttpEntity of the texts.
|
TextHttpEntity(ContentType contentType,
CharSequence... texts)
Create a TextHttpEntity of the texts.
|
TextHttpEntity(CharSequence... texts)
Create a TextHttpEntity of the texts, as
"text/plain;charset=UTF-8" . |
Instance Methods | |
---|---|
ByteSource |
body()
The entity body.
|
ContentType |
contentType()
The content type.
|
Long |
contentLength()
The length of the entity body.
|
Instant |
lastModified()
When this entity was last modified.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
bodyBytes, bodyString, contentEncoding, etag, etagIsWeak, expires
public TextHttpEntity(TextDoc doc)
public TextHttpEntity(ContentType contentType, Stream<? extends CharSequence> texts)
The content type should have a "charset" parameter, otherwise UTF-8 is used for encoding.
public TextHttpEntity(ContentType contentType, CharSequence... texts)
The content type should have a "charset" parameter, otherwise UTF-8 is used for encoding.
public TextHttpEntity(CharSequence... texts)
"text/plain;charset=UTF-8"
.public ByteSource body()
The entity body is a sequence of bytes encoding the texts, using the charset specified in the content type.
body
in interface HttpEntity
public ContentType contentType()
contentType
in interface HttpEntity
public Long contentLength()
This implementation may return null, because it's difficult to know the length without actually performing the encoding.
contentLength
in interface HttpEntity
public Instant lastModified()
This implementation returns the time this object was instantiated.
lastModified
in interface HttpEntity