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.param: reportContentLength Only applies for HTTP/2 responses, if false, do not produce a Content-Length header
- 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)Strict(ContentType contentType, akka.util.ByteString data, boolean reportContentLength)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanEqual(java.lang.Object o)longcontentLength()scala.Option<java.lang.Object>contentLengthOption()Some(content length) if a length is defined for this entity, None otherwise.ContentTypecontentType()TheContentTypeassociated with this entity.HttpEntity.Strictcopy(ContentType contentType, akka.util.ByteString data)akka.util.ByteStringdata()akka.stream.scaladsl.Source<akka.util.ByteString,akka.NotUsed>dataBytes()A stream of the data of this entity.booleanequals(java.lang.Object other)akka.util.ByteStringgetData()Java APIinthashCode()booleanisKnownEmpty()Returns if this entity is known to be empty.booleanisStrict()Returns if this entity is a subtype of HttpEntityStrict.intproductArity()java.lang.ObjectproductElement(int n)java.lang.StringproductPrefix()booleanreportContentLength()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.StringtoString()RequestEntitytransformDataBytes(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.StrictwithContentType(ContentType contentType)Creates a copy of this HttpEntity with thecontentTypeoverridden with the given one.HttpEntity.StrictwithoutContentLengthReporting()Only applies for HTTP/2 responses, leads to a response without Content-Length headerUniversalEntitywithoutSizeLimit()Lift the size limit from this entity by returning a new entity instance which skips the size verification.UniversalEntitywithSizeLimit(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, finalize, getClass, 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
-
-
-
-
Constructor Detail
-
Strict
public Strict(ContentType contentType, akka.util.ByteString data, boolean reportContentLength)
-
Strict
public Strict(ContentType contentType, akka.util.ByteString data)
-
-
Method Detail
-
contentType
public ContentType contentType()
Description copied from interface:HttpEntityTheContentTypeassociated with this entity.- Specified by:
contentTypein interfaceHttpEntity- Returns:
- (undocumented)
-
data
public akka.util.ByteString data()
-
reportContentLength
public boolean reportContentLength()
-
contentLength
public long contentLength()
- Specified by:
contentLengthin interfaceUniversalEntity
-
contentLengthOption
public scala.Option<java.lang.Object> contentLengthOption()
Description copied from interface:HttpEntitySome(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:
contentLengthOptionin interfaceHttpEntity- Specified by:
contentLengthOptionin interfaceUniversalEntity- Returns:
- (undocumented)
-
isKnownEmpty
public boolean isKnownEmpty()
Description copied from interface:HttpEntityReturns if this entity is known to be empty. Open-ended entity types like HttpEntityChunked and HttpCloseDelimited will always return false here.- Specified by:
isKnownEmptyin interfaceHttpEntity- Specified by:
isKnownEmptyin interfaceHttpEntity- Returns:
- (undocumented)
-
isStrict
public boolean isStrict()
Description copied from interface:HttpEntityReturns if this entity is a subtype of HttpEntityStrict.- Specified by:
isStrictin interfaceHttpEntity- Specified by:
isStrictin interfaceHttpEntity
-
dataBytes
public akka.stream.scaladsl.Source<akka.util.ByteString,akka.NotUsed> dataBytes()
Description copied from interface:HttpEntityA stream of the data of this entity.- Specified by:
dataBytesin interfaceHttpEntity- Returns:
- (undocumented)
-
toStrict
public scala.concurrent.Future<HttpEntity.Strict> toStrict(scala.concurrent.duration.FiniteDuration timeout, akka.stream.Materializer fm)
Description copied from interface:HttpEntityCollects 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 thetoStrictmethod and pass in an explicit maximum number of bytes.- Specified by:
toStrictin 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:HttpEntityReturns a copy of the given entity with the ByteString chunks of this entity transformed by the given transformer. For aChunkedentity, the chunks will be transformed one by one keeping the chunk metadata (but may introduce an extra chunk before theLastChunkiftransformer.onTerminationreturns additional data).This method may only throw an exception if the
transformerfunction throws an exception while creating the transformer. Any other errors are reported through the new entity data stream.- Specified by:
transformDataBytesin interfaceHttpEntity- Specified by:
transformDataBytesin interfaceRequestEntity- Specified by:
transformDataBytesin interfaceResponseEntity- Parameters:
transformer- (undocumented)- Returns:
- (undocumented)
-
withContentType
public HttpEntity.Strict withContentType(ContentType contentType)
Description copied from interface:HttpEntityCreates a copy of this HttpEntity with thecontentTypeoverridden with the given one.- Specified by:
withContentTypein interfaceBodyPartEntity- Specified by:
withContentTypein interfaceHttpEntity- Specified by:
withContentTypein interfaceRequestEntity- Specified by:
withContentTypein interfaceResponseEntity- Specified by:
withContentTypein interfaceUniversalEntity- Parameters:
contentType- (undocumented)- Returns:
- (undocumented)
-
withSizeLimit
public UniversalEntity withSizeLimit(long maxBytes)
Description copied from interface:HttpEntityApply 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:
withSizeLimitin interfaceBodyPartEntity- Specified by:
withSizeLimitin interfaceHttpEntity- Specified by:
withSizeLimitin interfaceHttpEntity- Specified by:
withSizeLimitin interfaceRequestEntity- Specified by:
withSizeLimitin interfaceResponseEntity- Specified by:
withSizeLimitin interfaceUniversalEntity- Parameters:
maxBytes- (undocumented)- Returns:
- (undocumented)
-
withoutSizeLimit
public UniversalEntity withoutSizeLimit()
Description copied from interface:HttpEntityLift 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:
withoutSizeLimitin interfaceBodyPartEntity- Specified by:
withoutSizeLimitin interfaceHttpEntity- Specified by:
withoutSizeLimitin interfaceHttpEntity- Specified by:
withoutSizeLimitin interfaceRequestEntity- Specified by:
withoutSizeLimitin interfaceResponseEntity- Specified by:
withoutSizeLimitin interfaceUniversalEntity- Returns:
- (undocumented)
-
withoutContentLengthReporting
public HttpEntity.Strict withoutContentLengthReporting()
Only applies for HTTP/2 responses, leads to a response without Content-Length header- Specified by:
withoutContentLengthReportingin interfaceHttpEntity.Strict- Returns:
- (undocumented)
-
productPrefix
public java.lang.String productPrefix()
- Specified by:
productPrefixin interfacescala.Product
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getData
public akka.util.ByteString getData()
Java API- Specified by:
getDatain interfaceHttpEntity.Strict
-
copy
public HttpEntity.Strict copy(ContentType contentType, akka.util.ByteString data)
-
productArity
public int productArity()
- Specified by:
productArityin interfacescala.Product
-
productElement
public java.lang.Object productElement(int n)
- Specified by:
productElementin interfacescala.Product
-
canEqual
public boolean canEqual(java.lang.Object o)
- Specified by:
canEqualin interfacescala.Equals
-
equals
public boolean equals(java.lang.Object other)
- Specified by:
equalsin interfacescala.Equals- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-