withoutSizeLimit

Signature

def withoutSizeLimit: Directive0

Description

Skips request entity size verification.

The whole mechanism of entity size checking is intended to prevent certain Denial-of-Service attacks. So suggested setup is to have akka.http.parsing.max-content-length relatively low and use withoutSizeLimit directive just for endpoints for which size verification should not be performed.

See also withSizeLimit for setting request entity size limit.

Example

val route =
  withoutSizeLimit {
    entity(as[String]) { _ ⇒
      complete(HttpResponse())
    }
  }

// tests:
def entityOfSize(size: Int) =
  HttpEntity(ContentTypes.`text/plain(UTF-8)`, "0" * size)

// will work even if you have configured akka.http.parsing.max-content-length = 500
Post("/abc", entityOfSize(501)) ~> route ~> check {
  status shouldEqual StatusCodes.OK
}
The source code for this page can be found here.