Http.reply.drain: def of bend-kit-http@0.38.2.0 Import: import bend-kit-http@0.38.2.0/http.bend as Http Lines 5595-5615 of bend-kit-http@0.38.2.0/http.bend: https://jend.leeeet.dev/read.txt?path=bend-kit-http@0.38.2.0/http.bend&start_line=5595&end_line=5615 import Base import bend-kit-wire@0.4.7.0/wire.bend as Wire import bend-kit-time@0.3.0.0/time.bend as Time # ponytail: cap drain at 32 MiB and 2.55 s; use socket half-close if larger peers need guaranteed delivery. def reply.drain(n: Nat, alive: Bool, +until: Time.Duration, st: Socket & Bool) -> IO(Unit): match n: case 0n: (s, more) = st Socket.close(s) case 1n+p: match alive: case False{}: (s, more) = st Socket.close(s) case True{}: (s, more) = st match more: case False{}: Socket.close(s) case True{}: do IO: got : Socket & Result<&1, &1, U32 & String, U32 & Array> <- Wire.recv.words(s, 65536, 50) now : Time.Duration <- Time.mono() reply.drain(p, Cmp.is_lt(Time.Duration.cmp(now, until)), until, reply.drain.of(got)) Uses (19): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Cmp.is_lt https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO.bind https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Socket https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Socket.close https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Unit https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.2.0/http.bend&name=reply.drain.of https://jend.leeeet.dev/definition.txt?path=bend-kit-time@0.3.0.0/time.bend&name=Duration https://jend.leeeet.dev/definition.txt?path=bend-kit-time@0.3.0.0/time.bend&name=Duration.cmp https://jend.leeeet.dev/definition.txt?path=bend-kit-time@0.3.0.0/time.bend&name=mono https://jend.leeeet.dev/definition.txt?path=bend-kit-wire@0.4.8.0/wire.bend&name=recv.words