def phase.after

bend-kit-http@0.38.4.0 · http.bend:6039

import bend-kit-http@0.38.4.0/http.bend as Http
import Base
import bend-kit-time@0.3.0.0/time.bend as Time

6039def phase.after(+settings: Limits, +now: Time.Duration, +phase: Phase, t: Turn) -> Turn & Phase:
6040  Limits{max, cap, hm, bm, im, wm} = settings
6041  Phase{+kind, until} = phase
6042  match t:
6043    case TurnMore{sv, cont}:
6044      match sv:
6045        case SvHead{buf}:
6046          (TurnMore{SvHead{buf}, cont}, Bool.pick(Phase, U32.is_zero(kind), phase.new(1, hm, now), phase))
6047        case SvLen{req, v11, left, parts}:
6048          (TurnMore{SvLen{req, v11, left, parts}, cont}, Bool.pick(Phase, U32.is_eq(kind, 2), phase, phase.new(2, bm, now)))
6049        case SvChunk{req, v11, n, st, parts}:
6050          (TurnMore{SvChunk{req, v11, n, st, parts}, cont}, Bool.pick(Phase, U32.is_eq(kind, 2), phase, phase.new(2, bm, now)))
6051    case TurnReq{req, rest, v11}:
6052      (TurnReq{req, rest, v11}, phase)
6053    case TurnFail{+status}:
6054      (Bool.pick(Turn, U32.is_zero(kind) && U32.is_eq(status, 408), TurnClose{}, TurnFail{status}), phase)
6055    case TurnClose{}:
6056      (TurnClose{}, phase)
6057    case TurnInputFailed{operation, code, message}:
6058      (TurnInputFailed{operation, code, message}, phase)

Uses (12)

Used by (1)