Package play.http
Class HttpEntity
java.lang.Object
play.http.HttpEntity
- Direct Known Subclasses:
HttpEntity.Chunked,HttpEntity.Streamed,HttpEntity.Strict
An HTTP entity
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA chunked entity, backed by a source of chunks.static final classA streamed entity, backed by a source.static final classA strict entity, where all the data for it is in memory. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionabstract HttpEntityabstract play.api.http.HttpEntityasScala()static final HttpEntitychunked(Source<ByteString, ?> data, Optional<String> contentType) Convert the given source of ByteStrings to a chunked entity.consumeData(Materializer mat) Consumes the data.abstract Source<ByteString,?> static final HttpEntityfromContent(play.twirl.api.Content content, String charset) Create an entity from the given content.static final HttpEntityfromString(String content, String charset) Create an entity from the given String.abstract boolean
-
Field Details
-
NO_ENTITY
No entity.
-
-
Method Details
-
contentType
- Returns:
- The content type, if defined
-
isKnownEmpty
public abstract boolean isKnownEmpty()- Returns:
- Whether the entity is known to be empty or not.
-
contentLength
- Returns:
- The content length, if known
-
dataStream
- Returns:
- The stream of data.
-
as
- Parameters:
contentType- the content type to use, i.e. "text/html".- Returns:
- Return the entity as the given content type.
-
consumeData
Consumes the data.This method should be used carefully, since if the source represents an ephemeral stream, then the entity may not be usable after this method is invoked.
- Parameters:
mat- the application's materializer.- Returns:
- a CompletionStage holding the data
-
asScala
public abstract play.api.http.HttpEntity asScala() -
fromContent
Create an entity from the given content.- Parameters:
content- The content.charset- The charset.- Returns:
- the HTTP entity.
-
fromString
Create an entity from the given String.- Parameters:
content- The content.charset- The charset.- Returns:
- the HTTP entity.
-
chunked
Convert the given source of ByteStrings to a chunked entity.- Parameters:
data- The source.contentType- The optional content type.- Returns:
- The ByteStrings.
-