def stream.idle

bend-kit-http@0.38.5.0 · http.bend:5006

import bend-kit-http@0.38.5.0/http.bend as Http
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes

5006# An idle socket from the pool; an h2 session goes back, since a stream speaks HTTP/1.1.
5007def stream.idle(p: Pool, +ms: U32, +head: Bool, +idem: Bool, +key: String, route: Route,
5008    r: Bytes.Bytes & Bytes.Bytes, c: Conn) -> IO(Pool & Result<&1, &1, Err, Stream>):
5009  (wire, spare) = r
5010  match c:
5011    case Conn{tls, s}:
5012      do IO<Pool & Result<&1, &1, Err, Stream>>:
5013        x : Bool & Result<&1, &1, Err, Stream> <- stream.conn(Done{Conn{tls, s}}, ms, head, Some{key}, wire)
5014        stream.reused(p, ms, head, idem, key, route, spare, x)
5015    case ConnH2{s, client}:
5016      do IO<Pool & Result<&1, &1, Err, Stream>>:
5017        next : Pool <- pool.give(p, key, ConnH2{s, client})
5018        got : Result<&1, &1, Err, Stream> <- stream.fresh(ms, head, Some{key}, route, spare)
5019        return (next, got)

Uses (20)

Used by (1)