=htp simple head test to cheack manual completion with empty Source (#20853)
* simple head test to cheack manual completion with empty Source, for issue 20182
This commit is contained in:
parent
e7def17ce3
commit
421eb3d021
1 changed files with 25 additions and 1 deletions
|
|
@ -4,8 +4,12 @@
|
|||
|
||||
package akka.http.scaladsl.server.directives
|
||||
|
||||
import akka.http.scaladsl.model.{ StatusCodes, HttpMethods }
|
||||
import akka.http.scaladsl.model.{ ContentTypes, HttpEntity, StatusCodes, HttpMethods }
|
||||
import akka.http.scaladsl.server._
|
||||
import akka.stream.scaladsl.Source
|
||||
|
||||
import scala.concurrent.Await
|
||||
import scala.concurrent.duration.Duration
|
||||
|
||||
class MethodDirectivesSpec extends RoutingSpec {
|
||||
|
||||
|
|
@ -23,6 +27,26 @@ class MethodDirectivesSpec extends RoutingSpec {
|
|||
}
|
||||
}
|
||||
|
||||
"head" should {
|
||||
val headRoute = head {
|
||||
complete(HttpEntity.Default(
|
||||
ContentTypes.`application/octet-stream`,
|
||||
12345L,
|
||||
Source.empty
|
||||
))
|
||||
}
|
||||
|
||||
"allow manual complete" in {
|
||||
Head() ~> headRoute ~> check {
|
||||
status shouldEqual StatusCodes.OK
|
||||
|
||||
val lengthF = response._3.dataBytes.runFold(0)((c, _) => c+1)
|
||||
val length = Await.result(lengthF, Duration(100, "millis"))
|
||||
length shouldEqual 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"two failed `get` directives" should {
|
||||
"only result in a single Rejection" in {
|
||||
Put() ~> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue