trait RequestEntity extends ResponseEntity
Marker-interface for entity types that can be used in a request
- Source
- RequestEntity.java
- Alphabetic
- By Inheritance
- RequestEntity
- ResponseEntity
- HttpEntity
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def discardBytes(system: ClassicActorSystemProvider): DiscardedEntity
Discards the entities data bytes by running the
dataBytes
Source contained in this entity.Discards the entities data bytes by running the
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.
- Definition Classes
- HttpEntity
- abstract def discardBytes(materializer: Materializer): DiscardedEntity
Discards the entities data bytes by running the
dataBytes
Source contained in this entity.Discards the entities data bytes by running the
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.
- Definition Classes
- HttpEntity
- abstract def getContentLengthOption(): OptionalLong
Returns Some(contentLength) if the length is defined and none otherwise.
Returns Some(contentLength) if the length is defined and none otherwise.
- Definition Classes
- HttpEntity
- abstract def getContentType(): ContentType
Returns the content-type of this entity
Returns the content-type of this entity
- Definition Classes
- HttpEntity
- abstract def getDataBytes(): Source[ByteString, AnyRef]
Returns a stream of data bytes this entity consists of.
Returns a stream of data bytes this entity consists of.
- Definition Classes
- HttpEntity
- abstract def isChunked(): Boolean
Returns if this entity is a subtype of HttpEntityChunked.
Returns if this entity is a subtype of HttpEntityChunked.
- Definition Classes
- HttpEntity
- abstract def isCloseDelimited(): Boolean
Returns if this entity is a subtype of HttpEntityCloseDelimited.
Returns if this entity is a subtype of HttpEntityCloseDelimited.
- Definition Classes
- HttpEntity
- abstract def isDefault(): Boolean
Returns if this entity is a subtype of HttpEntityDefault.
Returns if this entity is a subtype of HttpEntityDefault.
- Definition Classes
- HttpEntity
- abstract def isIndefiniteLength(): Boolean
Returns if this entity is a subtype of HttpEntityIndefiniteLength.
Returns if this entity is a subtype of HttpEntityIndefiniteLength.
- Definition Classes
- HttpEntity
- abstract def isKnownEmpty(): Boolean
Returns if this entity is known to be empty.
Returns if this entity is known to be empty. Open-ended entity types like HttpEntityChunked and HttpCloseDelimited will always return false here.
- Definition Classes
- HttpEntity
- abstract def isStrict(): Boolean
Returns if this entity is a subtype of HttpEntityStrict.
Returns if this entity is a subtype of HttpEntityStrict.
- Definition Classes
- HttpEntity
- abstract def toStrict(timeoutMillis: Long, maxBytes: Long, system: ClassicActorSystemProvider): CompletionStage[Strict]
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.
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. As the duration of receiving the complete entity cannot be predicted, a timeout needs to be specified to guard the process against running and keeping resources infinitely.
Use getDataBytes and stream processing instead if the expected data is big or is likely to take a long time.
- Definition Classes
- HttpEntity
- abstract def toStrict(timeoutMillis: Long, system: ClassicActorSystemProvider): CompletionStage[Strict]
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.
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. As the duration of receiving the complete entity cannot be predicted, a timeout needs to be specified to guard the process against running and keeping resources infinitely.
Use getDataBytes and stream processing instead if the expected data is big or is likely to take a long time.
- Definition Classes
- HttpEntity
- abstract def toStrict(timeoutMillis: Long, maxBytes: Long, materializer: Materializer): CompletionStage[Strict]
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.
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. As the duration of receiving the complete entity cannot be predicted, a timeout needs to be specified to guard the process against running and keeping resources infinitely.
Use getDataBytes and stream processing instead if the expected data is big or is likely to take a long time.
- Definition Classes
- HttpEntity
- abstract def toStrict(timeoutMillis: Long, materializer: Materializer): CompletionStage[Strict]
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.
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. As the duration of receiving the complete entity cannot be predicted, a timeout needs to be specified to guard the process against running and keeping resources infinitely.
Use getDataBytes and stream processing instead if the expected data is big or is likely to take a long time.
- Definition Classes
- HttpEntity
- abstract def withContentType(contentType: ContentType): HttpEntity
Returns a copy of this entity with new content type./
Returns a copy of this entity with new content type./
- Definition Classes
- HttpEntity
- abstract def withSizeLimit(maxBytes: Long): 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.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 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.- Definition Classes
- HttpEntity
- abstract def withoutSizeLimit(): HttpEntity
Lift the size limit from this entity by returning a new entity instance which skips the size verification.
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.
- Definition Classes
- HttpEntity