Http.h2.loop: def of bend-kit-http@0.38.4.0 Import: import bend-kit-http@0.38.4.0/http.bend as Http Lines 3315-3372 of bend-kit-http@0.38.4.0/http.bend: https://jend.leeeet.dev/read.txt?path=bend-kit-http@0.38.4.0/http.bend&start_line=3315&end_line=3372 import Base import bend-kit-wire@0.4.8.0/wire.bend as Wire import bend-kit-http2@0.4.0.0/http2.bend as H2 def h2.loop(n: Nat, step: H2Step, +ms: U32, +used: U32) -> IO(Result<&1, &1, Err, Conn & Res>): match n: case 0n: match step: case H2Reply{s, reply}: h2.fail(s, ErrBad{}) case H2Sent{client, events, sent}: match sent: case Fail{e}: IO.pure(Result<&1, &1, Err, Conn & Res>, Fail{e}) case Done{s}: h2.fail(s, ErrBad{}) case H2Events{s, client, result}: h2.fail(s, ErrBad{}) case H2Received{client, answer}: (s, r) = answer h2.fail(s, ErrBad{}) case 1n+p: match step: case H2Reply{s, reply}: match reply: case H2.Failed{error}: h2.fail(s, ErrBad{}) case H2.Advanced{client, writes, events}: do IO>: sent : Result<&1, &1, Err, Socket> <- h2.send(writes, s) h2.loop(p, H2Sent{client, events, sent}, ms, used) case H2Sent{client, events, sent}: match sent: case Fail{e}: IO.pure(Result<&1, &1, Err, Conn & Res>, Fail{e}) case Done{s}: h2.loop(p, H2Events{s, client, List.foldl(~&1, ~H2.ClientEvent, ~Result<&1, &1, Err, Maybe<&1, Res>>, ~h2.event.fold, events, Done{None{}})}, ms, used) case H2Events{s, client, result}: match result: case Fail{e}: h2.fail(s, e) case Done{Some{res}}: IO.pure(Result<&1, &1, Err, Conn & Res>, Done{(ConnH2{s, client}, res)}) case Done{None{}}: do IO>: r : Socket & Result<&1, &1, U32 & String, U32 & Array> <- Wire.tls.recv.words(s, 16384, ms) h2.loop(p, H2Received{client, r}, ms, used) case H2Received{client, answer}: match answer: case (s, Fail{(+code, why)}): h2.fail(s, err.or_late(code, ErrRead{code, why})) case (s, Done{(0, buf)}): h2.fail(s, ErrBad{}) case (s, Done{(+len, buf)}): +total = (used + len : U32) h2.loop(p, h2.received.step(fetch.over(total), s, client, len, buf), ms, total) Uses (30): 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=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=List.foldl https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Maybe 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=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.add 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-http2@0.4.0.0/http2.bend&name=ClientEvent https://jend.leeeet.dev/definition.txt?path=bend-kit-http2@0.4.0.0/http2.bend&name=Reply https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.4.0/http.bend&name=Conn https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.4.0/http.bend&name=Err https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.4.0/http.bend&name=H2Step https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.4.0/http.bend&name=Res https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.4.0/http.bend&name=err.or_late https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.4.0/http.bend&name=fetch.over https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.4.0/http.bend&name=h2.event.fold https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.4.0/http.bend&name=h2.fail https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.4.0/http.bend&name=h2.received.step https://jend.leeeet.dev/definition.txt?path=bend-kit-http@0.38.4.0/http.bend&name=h2.send https://jend.leeeet.dev/definition.txt?path=bend-kit-wire@0.4.8.0/wire.bend&name=tls.recv.words