Class HttpEntity.Default

java.lang.Object
akka.http.scaladsl.model.HttpEntity.Default
All Implemented Interfaces:
BodyPartEntity, HttpEntity, HttpEntity.Default, RequestEntity, ResponseEntity, UniversalEntity, BodyPartEntity, HttpEntity, RequestEntity, ResponseEntity, UniversalEntity, Serializable, scala.Equals, scala.Product
Enclosing interface:
HttpEntity

public static final class HttpEntity.Default extends Object implements HttpEntity.Default, UniversalEntity, scala.Product, Serializable
The model for the entity of a "regular" unchunked HTTP message with a known non-zero length.
See Also:
  • Constructor Details

    • Default

      public Default(ContentType contentType, long contentLength, akka.stream.scaladsl.Source<akka.util.ByteString,Object> data)
  • Method Details

    • contentType

      public ContentType contentType()
      Description copied from interface: HttpEntity
      The ContentType associated with this entity.
      Specified by:
      contentType in interface HttpEntity
      Returns:
      (undocumented)
    • contentLength

      public long contentLength()
      Specified by:
      contentLength in interface UniversalEntity
    • data

      public akka.stream.scaladsl.Source<akka.util.ByteString,Object> data()
    • 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 interface HttpEntity
      Specified by:
      isKnownEmpty in interface HttpEntity
      Returns:
      (undocumented)
    • isDefault

      public boolean isDefault()
      Description copied from interface: HttpEntity
      Returns if this entity is a subtype of HttpEntityDefault.
      Specified by:
      isDefault in interface HttpEntity
      Specified by:
      isDefault in interface HttpEntity
    • dataBytes

      public akka.stream.scaladsl.Source<akka.util.ByteString,Object> dataBytes()
      Description copied from interface: HttpEntity
      A stream of the data of this entity.
      Specified by:
      dataBytes in interface HttpEntity
      Returns:
      (undocumented)
    • transformDataBytes

      public HttpEntity.Chunked transformDataBytes(akka.stream.scaladsl.Flow<akka.util.ByteString,akka.util.ByteString,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 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.

      Specified by:
      transformDataBytes in interface HttpEntity
      Specified by:
      transformDataBytes in interface RequestEntity
      Specified by:
      transformDataBytes in interface ResponseEntity
      Parameters:
      transformer - (undocumented)
      Returns:
      (undocumented)
    • withContentType

      public HttpEntity.Default withContentType(ContentType contentType)
      Description copied from interface: HttpEntity
      Creates a copy of this HttpEntity with the contentType overridden with the given one.
      Specified by:
      withContentType in interface BodyPartEntity
      Specified by:
      withContentType in interface HttpEntity
      Specified by:
      withContentType in interface RequestEntity
      Specified by:
      withContentType in interface ResponseEntity
      Specified by:
      withContentType in interface UniversalEntity
      Parameters:
      contentType - (undocumented)
      Returns:
      (undocumented)
    • withSizeLimit

      public HttpEntity.Default 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 interface BodyPartEntity
      Specified by:
      withSizeLimit in interface HttpEntity
      Specified by:
      withSizeLimit in interface HttpEntity
      Specified by:
      withSizeLimit in interface RequestEntity
      Specified by:
      withSizeLimit in interface ResponseEntity
      Specified by:
      withSizeLimit in interface UniversalEntity
      Parameters:
      maxBytes - (undocumented)
      Returns:
      (undocumented)
    • withoutSizeLimit

      public HttpEntity.Default 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 interface BodyPartEntity
      Specified by:
      withoutSizeLimit in interface HttpEntity
      Specified by:
      withoutSizeLimit in interface HttpEntity
      Specified by:
      withoutSizeLimit in interface RequestEntity
      Specified by:
      withoutSizeLimit in interface ResponseEntity
      Specified by:
      withoutSizeLimit in interface UniversalEntity
      Returns:
      (undocumented)
    • productPrefix

      public String productPrefix()
      Specified by:
      productPrefix in interface scala.Product
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getContentLength

      public long getContentLength()
      Java API
      Specified by:
      getContentLength in interface HttpEntity.Default