Interface HttpEntity.WithoutKnownLength
-
- All Superinterfaces:
HttpEntity
,HttpEntity
- All Known Implementing Classes:
HttpEntity.CloseDelimited
,HttpEntity.IndefiniteLength
- Enclosing interface:
- HttpEntity
public static interface HttpEntity.WithoutKnownLength extends HttpEntity
Supertype of CloseDelimited and IndefiniteLength.INTERNAL API
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface akka.http.scaladsl.model.HttpEntity
HttpEntity.Chunk, HttpEntity.Chunk$, HttpEntity.Chunked, HttpEntity.Chunked$, HttpEntity.ChunkStreamPart, HttpEntity.ChunkStreamPart$, HttpEntity.CloseDelimited, HttpEntity.CloseDelimited$, HttpEntity.Default, HttpEntity.Default$, HttpEntity.DiscardedEntity, HttpEntity.HttpEntityScalaDSLSugar, HttpEntity.HttpEntityScalaDSLSugar$, HttpEntity.IndefiniteLength, HttpEntity.IndefiniteLength$, HttpEntity.LastChunk, HttpEntity.LastChunk$, HttpEntity.Strict, HttpEntity.Strict$, HttpEntity.WithoutKnownLength
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description scala.Option<java.lang.Object>
contentLengthOption()
Some(content length) if a length is defined for this entity, None otherwise.ContentType
contentType()
TheContentType
associated with this entity.akka.stream.scaladsl.Source<akka.util.ByteString,java.lang.Object>
data()
akka.stream.scaladsl.Source<akka.util.ByteString,java.lang.Object>
dataBytes()
A stream of the data of this entity.boolean
isKnownEmpty()
Determines whether this entity is known to be empty.HttpEntity.WithoutKnownLength
transformDataBytes(akka.stream.scaladsl.Flow<akka.util.ByteString,akka.util.ByteString,java.lang.Object> transformer)
Returns a copy of the given entity with the ByteString chunks of this entity transformed by the given transformer.HttpEntity.WithoutKnownLength
withData(akka.stream.scaladsl.Source<akka.util.ByteString,java.lang.Object> data)
HttpEntity.WithoutKnownLength
withoutSizeLimit()
Lift the size limit from this entity by returning a new entity instance which skips the size verification.HttpEntity.WithoutKnownLength
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 mostmaxBytes
data bytes.-
Methods inherited from interface akka.http.scaladsl.model.HttpEntity
completionStageCovariant, discardBytes, discardBytes, getContentLengthOption, getContentType, getDataBytes, isChunked, isCloseDelimited, isDefault, isIndefiniteLength, isStrict, toStrict, toStrict, toStrict, toStrict, toStrict, toStrict, transformDataBytes, withContentType, withContentType
-
-
-
-
Method Detail
-
contentLengthOption
scala.Option<java.lang.Object> contentLengthOption()
Description copied from interface:HttpEntity
Some(content length) if a length is defined for this entity, None otherwise. A length is only defined for Strict and Default entity types.In many cases it's dangerous to rely on the (non-)existence of a content-length. HTTP intermediaries like (transparent) proxies are allowed to change the transfer-encoding which can result in the entity being delivered as another type as expected.
- Specified by:
contentLengthOption
in interfaceHttpEntity
- Returns:
- (undocumented)
-
contentType
ContentType contentType()
Description copied from interface:HttpEntity
TheContentType
associated with this entity.- Specified by:
contentType
in interfaceHttpEntity
- Returns:
- (undocumented)
-
data
akka.stream.scaladsl.Source<akka.util.ByteString,java.lang.Object> data()
-
dataBytes
akka.stream.scaladsl.Source<akka.util.ByteString,java.lang.Object> dataBytes()
Description copied from interface:HttpEntity
A stream of the data of this entity.- Specified by:
dataBytes
in interfaceHttpEntity
- Returns:
- (undocumented)
-
isKnownEmpty
boolean isKnownEmpty()
Description copied from interface:HttpEntity
Determines whether this entity is known to be empty.- Specified by:
isKnownEmpty
in interfaceHttpEntity
- Specified by:
isKnownEmpty
in interfaceHttpEntity
- Returns:
- (undocumented)
-
transformDataBytes
HttpEntity.WithoutKnownLength transformDataBytes(akka.stream.scaladsl.Flow<akka.util.ByteString,akka.util.ByteString,java.lang.Object> transformer)
Description copied from interface:HttpEntity
Returns a copy of the given entity with the ByteString chunks of this entity transformed by the given transformer. For aChunked
entity, the chunks will be transformed one by one keeping the chunk metadata (but may introduce an extra chunk before theLastChunk
iftransformer.onTermination
returns additional data).This method may only throw an exception if the
transformer
function throws an exception while creating the transformer. Any other errors are reported through the new entity data stream.- Specified by:
transformDataBytes
in interfaceHttpEntity
- Parameters:
transformer
- (undocumented)- Returns:
- (undocumented)
-
withData
HttpEntity.WithoutKnownLength withData(akka.stream.scaladsl.Source<akka.util.ByteString,java.lang.Object> data)
-
withSizeLimit
HttpEntity.WithoutKnownLength withSizeLimit(long maxBytes)
Description copied from interface:HttpEntity
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 mostmaxBytes
data bytes. In case this verification fails the respective stream will be terminated with anEntityStreamException
either directly at materialization time (if the Content-Length is known) or whenever more data bytes than allowed have been read.When called on
Strict
entities the method will return the entity itself if the length is within the bound, otherwise aDefault
entity with a single element data stream. This allows for potential refinement of the entity size limit at a later point (before materialization of the data stream).By default all message entities produced by the HTTP layer automatically carry the limit that is defined in the application's
max-content-length
config setting. If the entity is transformed in a way that changes the Content-Length and then another limit is applied then this new limit will be evaluated against the new Content-Length. If the entity is transformed in a way that changes the Content-Length and no new limit is applied then the previous limit will be applied against the previous Content-Length.- Specified by:
withSizeLimit
in interfaceHttpEntity
- Specified by:
withSizeLimit
in interfaceHttpEntity
- Parameters:
maxBytes
- (undocumented)- Returns:
- (undocumented)
-
withoutSizeLimit
HttpEntity.WithoutKnownLength withoutSizeLimit()
Description copied from interface:HttpEntity
Lift the size limit from this entity by returning a new entity instance which skips the size verification.By default all message entities produced by the HTTP layer automatically carry the limit that is defined in the application's
max-content-length
config setting. It is recommended to always keep an upper limit on accepted entities to avoid potential attackers flooding you with too large requests/responses, so use this method with caution.See
HttpEntity.withSizeLimit(long)
for more details.- Specified by:
withoutSizeLimit
in interfaceHttpEntity
- Specified by:
withoutSizeLimit
in interfaceHttpEntity
- Returns:
- (undocumented)
-
-