Some(content length) if a length is defined for this entity, None otherwise.
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.
The ContentType
associated with this entity.
The ContentType
associated with this entity.
A stream of the data of this entity.
A stream of the data of this entity.
Determines whether this entity is known to be empty.
Determines whether this entity is known to be empty.
Returns a copy of the given entity with the ByteString chunks of this entity transformed by the given transformer.
Returns a copy of the given entity with the ByteString chunks of this entity transformed by the given transformer.
For a Chunked
entity, the chunks will be transformed one by one keeping the chunk metadata (but may introduce an
extra chunk before the LastChunk
if transformer.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.
Creates a copy of this HttpEntity with the contentType
overridden with the given one.
Creates a copy of this HttpEntity with the contentType
overridden with the given one.
See HttpEntity#withoutSizeLimit.
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.scaladsl.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 entity.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.
Java API
Java API
Java API
Java API
Java API
Java API
Java API
Java API
Collects all possible parts and returns a potentially future Strict entity for easier processing.
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.
Java API
Java API
Some(content length) if a length is defined for this entity, None otherwise.
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.
(requestEntity: ResponseEntity).contentLengthOption
The ContentType
associated with this entity.
The ContentType
associated with this entity.
(requestEntity: ResponseEntity).contentType
A stream of the data of this entity.
A stream of the data of this entity.
(requestEntity: ResponseEntity).dataBytes
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.scaladsl.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 entity.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.
In future versions, more automatic ways to warn or resolve these situations may be introduced, see issue #18716.
(requestEntity: HttpEntityScalaDSLSugar).discardBytes()(mat)
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.scaladsl.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 entity.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.
(requestEntity: ResponseEntity).discardBytes(mat)
Java API
Java API
(requestEntity: ResponseEntity).getContentLengthOption()
Java API
Java API
(requestEntity: ResponseEntity).getContentType()
Java API
Java API
(requestEntity: ResponseEntity).getDataBytes()
(requestEntity: ResponseEntity).isChunked()
(requestEntity: ResponseEntity).isCloseDelimited()
(requestEntity: ResponseEntity).isDefault()
(requestEntity: ResponseEntity).isIndefiniteLength()
Determines whether this entity is known to be empty.
Determines whether this entity is known to be empty.
(requestEntity: ResponseEntity).isKnownEmpty()
Java API
Java API
(requestEntity: ResponseEntity).toStrict(timeoutMillis, materializer)
Collects all possible parts and returns a potentially future Strict entity for easier processing.
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.
(requestEntity: ResponseEntity).toStrict(timeout)(fm)
Returns a copy of the given entity with the ByteString chunks of this entity transformed by the given transformer.
Returns a copy of the given entity with the ByteString chunks of this entity transformed by the given transformer.
For a Chunked
entity, the chunks will be transformed one by one keeping the chunk metadata (but may introduce an
extra chunk before the LastChunk
if transformer.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.
(requestEntity: ResponseEntity).transformDataBytes(transformer)
Java API
Java API
(requestEntity: ResponseEntity).withContentType(contentType)
Creates a copy of this HttpEntity with the contentType
overridden with the given one.
Creates a copy of this HttpEntity with the contentType
overridden with the given one.
(requestEntity: ResponseEntity).withContentType(contentType)
(requestEntity: ResponseEntity).withSizeLimit(maxBytes)
See HttpEntity#withoutSizeLimit
(requestEntity: ResponseEntity).withoutSizeLimit()
An HttpEntity that can be used for requests. Note that all entities that can be used for requests can also be used for responses. (But not the other way around, since HttpEntity.CloseDelimited can only be used for responses!)