Http.talk.read.loop: def of bend-kit-http@0.38.2.0 Import: import bend-kit-http@0.38.2.0/http.bend as Http Lines 6099-6143 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=6099&end_line=6143 import Base import bend-kit-http@0.38.2.0/admission.bend as Admission import bend-kit-wire@0.4.7.0/wire.bend as Wire import bend-kit-time@0.3.0.0/time.bend as Time def talk.read.loop(+inbox: Chan(Admission.Command), +held: Bool, +settings: Limits, step: ReadStep) -> IO((Socket & Turn) & Phase): match step: case ReadChecking{s, sv, phase}: do IO<(Socket & Turn) & Phase>: running : Bool <- talk.read.running(held, inbox) talk.read.loop(inbox, held, settings, ReadAllowed{running, s, sv, phase}) case ReadAllowed{running, s, sv, +phase}: match running: case False{}: IO.pure((Socket & Turn) & Phase, ((s, TurnClose{}), phase)) case True{}: Phase{kind, until} = phase do IO<(Socket & Turn) & Phase>: now : Time.Duration <- Time.mono() +ms : U32 = phase.remaining(until, now) talk.read.loop(inbox, held, settings, ReadBudget{Bool.pick(U32, held, ms, U32.min(ms, 50)), s, sv, phase}) case ReadBudget{ms, s, sv, +phase}: match ms: case 0: IO.pure((Socket & Turn) & Phase, ((s, phase.expired(phase)), phase)) case _: do IO<(Socket & Turn) & Phase>: got : Socket & Result<&1, &1, U32 & String, U32 & Array> <- Wire.recv.words(s, 65536, ms) now : Time.Duration <- Time.mono() talk.read.loop(inbox, held, settings, ReadReceived{sv, phase, now, got}) case ReadReceived{sv, +phase, +now, got}: Phase{kind, until} = phase (s, result) = got match result: case Fail{(+code, message)}: talk.read.loop(inbox, held, settings, ReadFailed{err.late(code) && Cmp.is_lt(Time.Duration.cmp(now, until)), s, sv, phase, now, (code, message)}) case Done{packed}: IO.pure((Socket & Turn) & Phase, talk.received.late(Bool.not(Cmp.is_lt(Time.Duration.cmp(now, until))), settings, phase, now, sv, (s, Done{packed}))) case ReadFailed{retry, s, sv, +phase, +now, error}: match retry: case True{}: talk.read.loop(inbox, held, settings, ReadChecking{s, sv, phase}) case False{}: Phase{kind, until} = phase IO.pure((Socket & Turn) & Phase, talk.received.late(Bool.not(Cmp.is_lt(Time.Duration.cmp(now, until))), settings, phase, now, sv, (s, Fail{error}))) Uses (33): 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=Bool.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.not https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.pick https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Chan 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=IO.pure 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=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.min https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Word.Con https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Word.Nil https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.2.0/admission.bend&name=Command https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.2.0/http.bend&name=Limits https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.2.0/http.bend&name=Phase https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.2.0/http.bend&name=ReadStep https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.2.0/http.bend&name=Turn https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.2.0/http.bend&name=err.late https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.2.0/http.bend&name=phase.expired https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.2.0/http.bend&name=phase.remaining https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.2.0/http.bend&name=talk.read.running https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.2.0/http.bend&name=talk.received.late 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