@DoNotInherit
public interface HttpEntity
for javadsl convenience methods.
Modifier and Type | Interface and Description |
---|---|
static interface |
HttpEntity.Chunked
Represents an entity transferred using `Transfer-Encoding: chunked`.
|
static class |
HttpEntity.ChunkStreamPart
A part of a stream of incoming data for `Transfer-Encoding: chunked` messages.
|
static interface |
HttpEntity.CloseDelimited
Represents an entity without a predetermined content-length.
|
static interface |
HttpEntity.Default
The default entity type which has a predetermined length and a stream of data bytes.
|
static interface |
HttpEntity.DiscardedEntity
Represents the currently being-drained HTTP Entity which triggers completion of the contained
Future once the entity has been drained for the given HttpMessage completely.
|
static interface |
HttpEntity.IndefiniteLength
Represents an entity without a predetermined content-length to use in a BodyParts.
|
static interface |
HttpEntity.Strict
The entity type which consists of a predefined fixed ByteString of data.
|
Modifier and Type | Method and Description |
---|---|
HttpMessage.DiscardedEntity |
discardBytes(akka.actor.ClassicActorSystemProvider system)
Discards the entities data bytes by running the
dataBytes Source contained in this entity. |
HttpMessage.DiscardedEntity |
discardBytes(akka.stream.Materializer materializer)
Discards the entities data bytes by running the
dataBytes Source contained in this entity. |
java.util.OptionalLong |
getContentLengthOption()
Returns Some(contentLength) if the length is defined and none otherwise.
|
ContentType |
getContentType()
Returns the content-type of this entity
|
akka.stream.javadsl.Source<akka.util.ByteString,java.lang.Object> |
getDataBytes()
Returns a stream of data bytes this entity consists of.
|
boolean |
isChunked()
Returns if this entity is a subtype of HttpEntityChunked.
|
boolean |
isCloseDelimited()
Returns if this entity is a subtype of HttpEntityCloseDelimited.
|
boolean |
isDefault()
Returns if this entity is a subtype of HttpEntityDefault.
|
boolean |
isIndefiniteLength()
Returns if this entity is a subtype of HttpEntityIndefiniteLength.
|
boolean |
isKnownEmpty()
Returns if this entity is known to be empty.
|
boolean |
isStrict()
Returns if this entity is a subtype of HttpEntityStrict.
|
java.util.concurrent.CompletionStage<HttpEntity.Strict> |
toStrict(long timeoutMillis,
akka.actor.ClassicActorSystemProvider system)
Returns a CompletionStage of a strict entity that contains the same data as this entity
which is only completed when the complete entity has been collected.
|
java.util.concurrent.CompletionStage<HttpEntity.Strict> |
toStrict(long timeoutMillis,
long maxBytes,
akka.actor.ClassicActorSystemProvider system)
Returns a CompletionStage of a strict entity that contains the same data as this entity
which is only completed when the complete entity has been collected.
|
java.util.concurrent.CompletionStage<HttpEntity.Strict> |
toStrict(long timeoutMillis,
long maxBytes,
akka.stream.Materializer materializer)
Returns a CompletionStage of a strict entity that contains the same data as this entity
which is only completed when the complete entity has been collected.
|
java.util.concurrent.CompletionStage<HttpEntity.Strict> |
toStrict(long timeoutMillis,
akka.stream.Materializer materializer)
Returns a CompletionStage of a strict entity that contains the same data as this entity
which is only completed when the complete entity has been collected.
|
HttpEntity |
withContentType(ContentType contentType)
Returns a copy of this entity with new content type
|
HttpEntity |
withoutSizeLimit()
Lift the size limit from this entity by returning a new entity instance which skips the size verification.
|
HttpEntity |
withSizeLimit(long maxBytes)
Apply the given size limit to this entity by returning a new entity instance which automatically verifies that the
data stream encapsulated by this instance produces at most `maxBytes` data bytes.
|
ContentType getContentType()
HttpEntity withContentType(ContentType contentType)
boolean isKnownEmpty()
boolean isChunked()
boolean isStrict()
boolean isDefault()
boolean isCloseDelimited()
boolean isIndefiniteLength()
java.util.OptionalLong getContentLengthOption()
akka.stream.javadsl.Source<akka.util.ByteString,java.lang.Object> getDataBytes()
HttpEntity withSizeLimit(long maxBytes)
HttpEntity withoutSizeLimit()
java.util.concurrent.CompletionStage<HttpEntity.Strict> toStrict(long timeoutMillis, akka.stream.Materializer materializer)
java.util.concurrent.CompletionStage<HttpEntity.Strict> toStrict(long timeoutMillis, long maxBytes, akka.stream.Materializer materializer)
java.util.concurrent.CompletionStage<HttpEntity.Strict> toStrict(long timeoutMillis, akka.actor.ClassicActorSystemProvider system)
java.util.concurrent.CompletionStage<HttpEntity.Strict> toStrict(long timeoutMillis, long maxBytes, akka.actor.ClassicActorSystemProvider system)
HttpMessage.DiscardedEntity discardBytes(akka.stream.Materializer materializer)
dataBytes
Source contained in this entity.
Note: It is crucial that entities are either discarded, or consumed by running the underlying [[akka.stream.javadsl.Source]]
as otherwise the lack of consuming of the data will trigger back-pressure to the underlying TCP connection
(as designed), however possibly leading to an idle-timeout that will close the connection, instead of
just having ignored the data.
Warning: It is not allowed to discard and/or consume the dataBytes
more than once
as the stream is directly attached to the "live" incoming data source from the underlying TCP connection.
Allowing it to be consumable twice would require buffering the incoming data, thus defeating the purpose
of its streaming nature. If the dataBytes source is materialized a second time, it will fail with an
"stream can cannot be materialized more than once" exception.
When called on `Strict` entities or sources whose values can be buffered in memory,
the above warnings can be ignored. Repeated materialization is not necessary in this case, avoiding
the mentioned exceptions due to the data being held in memory.
In future versions, more automatic ways to warn or resolve these situations may be introduced, see issue #18716.HttpMessage.DiscardedEntity discardBytes(akka.actor.ClassicActorSystemProvider system)
dataBytes
Source contained in this entity.
Note: It is crucial that entities are either discarded, or consumed by running the underlying [[akka.stream.javadsl.Source]]
as otherwise the lack of consuming of the data will trigger back-pressure to the underlying TCP connection
(as designed), however possibly leading to an idle-timeout that will close the connection, instead of
just having ignored the data.
Warning: It is not allowed to discard and/or consume the dataBytes
more than once
as the stream is directly attached to the "live" incoming data source from the underlying TCP connection.
Allowing it to be consumable twice would require buffering the incoming data, thus defeating the purpose
of its streaming nature. If the dataBytes source is materialized a second time, it will fail with an
"stream can cannot be materialized more than once" exception.
When called on `Strict` entities or sources whose values can be buffered in memory,
the above warnings can be ignored. Repeated materialization is not necessary in this case, avoiding
the mentioned exceptions due to the data being held in memory.
In future versions, more automatic ways to warn or resolve these situations may be introduced, see issue #18716.