Scoop API

scoop:scoop.http.server:0.1.0

src/http2_watch.scoop

Selected production source · src/http2_watch.scoop

1package scoop.http.server
3import scoop.http.asyncio.AsyncHttp2Connection
4import scoop.time.Duration
6internal suspend fun watchServerHttp2(activity: ServerHttp2, connection: AsyncHttp2Connection, owner: Job) {
7 try {
8 while (true) {
9 if (activity.takeDrainRequest() && !connection.isDraining) connection.goAway()
10 if (connection.isDraining) return
11 val deadline = activity.nextDeadline()
12 try {
13 val remaining: Duration? = when (deadline) { case None -> None; case Some(val value) -> Some(value.remaining()) }
14 serverDeadline<Unit>(remaining, "HTTP/2 connection wait", suspend { activity.changes.await() })
15 } catch (_: HttpServerTimeoutException) {
16 val current = activity.nextDeadline()
17 if (present(current) && current!!.remaining() == Duration.ZERO)
18 throw HttpServerTimeoutException(current!!.operation, current!!.limit)
19 }
20 }
21 } catch (error: Throwable) {
22 if (!(error is CancellationException)) { activity.fail(error); owner.cancel() }
23 }