Open
Description
When a service yields a task that takes a long time to produce a response (see /slow
in the code below), the Blaze backend will drop the socket after idleTimeout
has elapsed. The Jetty backend:
- Keeps the connection open for 30 seconds, ignoring
idleTimeout
. - Then returns a 200 OK with no body.
import scala.concurrent.duration._
import scalaz.concurrent._
import org.http4s.dsl._
import org.http4s.server._
object JettyTest extends App {
val service = HttpService {
case GET -> Root / "slow" => for {
_ <- Task.delay { Thread.sleep(45*1000) }
resp <- InternalServerError("finally!")
} yield resp
case GET -> Root / "fail" => Task.fail(new RuntimeException)
}
val js = org.http4s.server.jetty.JettyBuilder
.withIdleTimeout(1.second)
.bindHttp(8080, "0.0.0.0")
.mountService(service)
val bs = org.http4s.server.blaze.BlazeBuilder
.withIdleTimeout(1.second)
.bindHttp(8180, "0.0.0.0")
.mountService(service)
js.run
bs.run
}
Using http4s 0.8.2.