Package akka.http.scaladsl.model
Class HttpEntity.Strict
- java.lang.Object
-
- akka.http.scaladsl.model.HttpEntity.Strict
-
- All Implemented Interfaces:
BodyPartEntity
,HttpEntity
,HttpEntity.Strict
,RequestEntity
,ResponseEntity
,UniversalEntity
,BodyPartEntity
,HttpEntity
,RequestEntity
,ResponseEntity
,UniversalEntity
,java.io.Serializable
,scala.Equals
,scala.Product
- Enclosing interface:
- HttpEntity
public static final class HttpEntity.Strict extends java.lang.Object implements HttpEntity.Strict, UniversalEntity, scala.Product, java.io.Serializable
The model for the entity of a "regular" unchunked HTTP message with known, fixed data.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface akka.http.javadsl.model.HttpEntity
HttpEntity.Chunked, HttpEntity.ChunkStreamPart, HttpEntity.CloseDelimited, HttpEntity.Default, HttpEntity.DiscardedEntity, HttpEntity.IndefiniteLength, HttpEntity.Strict
-
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
-
-
Constructor Summary
Constructors Constructor Description Strict(ContentType contentType, akka.util.ByteString data)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
contentLength()
ContentType
contentType()
TheContentType
associated with this entity.akka.util.ByteString
data()
akka.stream.scaladsl.Source<akka.util.ByteString,akka.NotUsed>
dataBytes()
A stream of the data of this entity.akka.util.ByteString
getData()
Java APIboolean
isKnownEmpty()
Returns if this entity is known to be empty.boolean
isStrict()
Returns if this entity is a subtype of HttpEntityStrict.java.lang.String
productPrefix()
scala.concurrent.Future<HttpEntity.Strict>
toStrict(scala.concurrent.duration.FiniteDuration timeout, akka.stream.Materializer fm)
Collects all possible parts and returns a potentially future Strict entity for easier processing.java.lang.String
toString()
RequestEntity
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.Strict
withContentType(ContentType contentType)
Creates a copy of this HttpEntity with thecontentType
overridden with the given one.UniversalEntity
withoutSizeLimit()
Lift the size limit from this entity by returning a new entity instance which skips the size verification.UniversalEntity
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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface akka.http.scaladsl.model.HttpEntity
completionStageCovariant, discardBytes, discardBytes, getContentLengthOption, getContentType, getDataBytes, isChunked, isCloseDelimited, isDefault, isIndefiniteLength, toStrict, toStrict, toStrict, toStrict, toStrict, transformDataBytes, withContentType
-
Methods inherited from interface scala.Product
productArity, productElement, productElementName, productElementNames, productIterator
-
Methods inherited from interface akka.http.scaladsl.model.UniversalEntity
contentLengthOption
-
-
-
-
Constructor Detail
-
Strict
public Strict(ContentType contentType, akka.util.ByteString data)
-
-
Method Detail
-
contentType
public ContentType contentType()
Description copied from interface:HttpEntity
TheContentType
associated with this entity.- Specified by:
contentType
in interfaceHttpEntity
- Returns:
- (undocumented)
-
data
public akka.util.ByteString data()
-
contentLength
public long contentLength()
- Specified by:
contentLength
in interfaceUniversalEntity
-
isKnownEmpty
public boolean isKnownEmpty()
Description copied from interface:HttpEntity
Returns if this entity is known to be empty. Open-ended entity types like HttpEntityChunked and HttpCloseDelimited will always return false here.- Specified by:
isKnownEmpty
in interfaceHttpEntity
- Specified by:
isKnownEmpty
in interfaceHttpEntity
- Returns:
- (undocumented)
-
isStrict
public boolean isStrict()
Description copied from interface:HttpEntity
Returns if this entity is a subtype of HttpEntityStrict.- Specified by:
isStrict
in interfaceHttpEntity
- Specified by:
isStrict
in interfaceHttpEntity
-
dataBytes
public akka.stream.scaladsl.Source<akka.util.ByteString,akka.NotUsed> dataBytes()
Description copied from interface:HttpEntity
A stream of the data of this entity.- Specified by:
dataBytes
in interfaceHttpEntity
- Returns:
- (undocumented)
-
toStrict
public scala.concurrent.Future<HttpEntity.Strict> toStrict(scala.concurrent.duration.FiniteDuration timeout, akka.stream.Materializer fm)
Description copied from interface:HttpEntity
Collects all possible parts and returns a potentially future Strict entity for easier processing. The Future is failed with an TimeoutException if the stream isn't completed after the given timeout, or with a EntityStreamException when the end of the entity is not reached within the maximum number of bytes as configured inakka.http.parsing.max-to-strict-bytes
. Not that this method does not support different defaults for client- and server use: if you want that, use thetoStrict
method and pass in an explicit maximum number of bytes.- Specified by:
toStrict
in interfaceHttpEntity
- Parameters:
timeout
- (undocumented)fm
- (undocumented)- Returns:
- (undocumented)
-
transformDataBytes
public RequestEntity 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
- Specified by:
transformDataBytes
in interfaceRequestEntity
- Specified by:
transformDataBytes
in interfaceResponseEntity
- Parameters:
transformer
- (undocumented)- Returns:
- (undocumented)
-
withContentType
public HttpEntity.Strict withContentType(ContentType contentType)
Description copied from interface:HttpEntity
Creates a copy of this HttpEntity with thecontentType
overridden with the given one.- Specified by:
withContentType
in interfaceBodyPartEntity
- Specified by:
withContentType
in interfaceHttpEntity
- Specified by:
withContentType
in interfaceRequestEntity
- Specified by:
withContentType
in interfaceResponseEntity
- Specified by:
withContentType
in interfaceUniversalEntity
- Parameters:
contentType
- (undocumented)- Returns:
- (undocumented)
-
withSizeLimit
public UniversalEntity 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 most `maxBytes` data bytes. In case this verification fails the respective stream will be terminated with an `EntityStreamException` 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 a `Default` 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 interfaceBodyPartEntity
- Specified by:
withSizeLimit
in interfaceHttpEntity
- Specified by:
withSizeLimit
in interfaceHttpEntity
- Specified by:
withSizeLimit
in interfaceRequestEntity
- Specified by:
withSizeLimit
in interfaceResponseEntity
- Specified by:
withSizeLimit
in interfaceUniversalEntity
- Parameters:
maxBytes
- (undocumented)- Returns:
- (undocumented)
-
withoutSizeLimit
public UniversalEntity 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 [[withSizeLimit]] for more details.- Specified by:
withoutSizeLimit
in interfaceBodyPartEntity
- Specified by:
withoutSizeLimit
in interfaceHttpEntity
- Specified by:
withoutSizeLimit
in interfaceHttpEntity
- Specified by:
withoutSizeLimit
in interfaceRequestEntity
- Specified by:
withoutSizeLimit
in interfaceResponseEntity
- Specified by:
withoutSizeLimit
in interfaceUniversalEntity
- Returns:
- (undocumented)
-
productPrefix
public java.lang.String productPrefix()
- Specified by:
productPrefix
in interfacescala.Product
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getData
public akka.util.ByteString getData()
Java API- Specified by:
getData
in interfaceHttpEntity.Strict
-
-