Class HttpEntity.Default
- All Implemented Interfaces:
Serializable,BodyPartEntity,HttpEntity,HttpEntity.Default,RequestEntity,ResponseEntity,UniversalEntity,BodyPartEntity,HttpEntity,RequestEntity,ResponseEntity,UniversalEntity,scala.Equals,scala.Product
- Enclosing interface:
- HttpEntity
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.pekko.http.javadsl.model.HttpEntity
HttpEntity.Chunked, HttpEntity.ChunkStreamPart, HttpEntity.CloseDelimited, HttpEntity.Default, HttpEntity.DiscardedEntity, HttpEntity.IndefiniteLength, HttpEntity.StrictNested classes/interfaces inherited from interface org.apache.pekko.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
ConstructorsConstructorDescriptionDefault(ContentType contentType, long contentLength, org.apache.pekko.stream.scaladsl.Source<org.apache.pekko.util.ByteString, Object> data) -
Method Summary
Modifier and TypeMethodDescriptionlongTheContentTypeassociated with this entity.org.apache.pekko.stream.scaladsl.Source<org.apache.pekko.util.ByteString,Object> data()org.apache.pekko.stream.scaladsl.Source<org.apache.pekko.util.ByteString,Object> A stream of the data of this entity.longJava APIbooleanReturns if this entity is a subtype of HttpEntityDefault.booleanReturns if this entity is known to be empty.toString()transformDataBytes(org.apache.pekko.stream.scaladsl.Flow<org.apache.pekko.util.ByteString, org.apache.pekko.util.ByteString, Object> transformer) Returns a copy of the given entity with the ByteString chunks of this entity transformed by the given transformer.withContentType(ContentType contentType) Creates a copy of this HttpEntity with thecontentTypeoverridden with the given one.Lift the size limit from this entity by returning a new entity instance which skips the size verification.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, waitMethods inherited from interface scala.Equals
canEqual, equalsMethods inherited from interface org.apache.pekko.http.scaladsl.model.HttpEntity
completionStageCovariant, discardBytes, discardBytes, getContentLengthOption, getContentType, getDataBytes, isChunked, isCloseDelimited, isIndefiniteLength, isStrict, toStrict, toStrict, toStrict, toStrict, toStrict, toStrict, transformDataBytes, withContentTypeMethods inherited from interface scala.Product
productArity, productElement, productElementName, productElementNames, productIteratorMethods inherited from interface org.apache.pekko.http.scaladsl.model.UniversalEntity
contentLengthOption
-
Constructor Details
-
Default
public Default(ContentType contentType, long contentLength, org.apache.pekko.stream.scaladsl.Source<org.apache.pekko.util.ByteString, Object> data)
-
-
Method Details
-
contentType
Description copied from interface:HttpEntityTheContentTypeassociated with this entity.- Specified by:
contentTypein interfaceHttpEntity- Returns:
- (undocumented)
-
contentLength
public long contentLength()- Specified by:
contentLengthin interfaceUniversalEntity
-
data
-
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)
-
isDefault
public boolean isDefault()Description copied from interface:HttpEntityReturns if this entity is a subtype of HttpEntityDefault.- Specified by:
isDefaultin interfaceHttpEntity- Specified by:
isDefaultin interfaceHttpEntity
-
dataBytes
Description copied from interface:HttpEntityA stream of the data of this entity.- Specified by:
dataBytesin interfaceHttpEntity- Returns:
- (undocumented)
-
transformDataBytes
public HttpEntity.Chunked transformDataBytes(org.apache.pekko.stream.scaladsl.Flow<org.apache.pekko.util.ByteString, org.apache.pekko.util.ByteString, 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
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
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
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)
-
productPrefix
- Specified by:
productPrefixin interfacescala.Product
-
toString
-
getContentLength
public long getContentLength()Java API- Specified by:
getContentLengthin interfaceHttpEntity.Default
-