src/step.bend checks
raw source on the hub · import ezhttp@0.24.0.0/src/step.bend as Step
ezhttp/src/step: what the server decides for one connection, kept pure so a law can state it. server.bend runs the effects and asks this module what each outcome means; it decides nothing itself.
3 imports
import Base import ./http.bend as Http import ./qs.bend as Qs
Types
type Step source · line 9 · raw
Data
what a request asks of the server: answer it now, or call the handler
Answer@reply:0x8673751971e75cc0377d73b25bc4d890/src/http.Reply -> Step
Call@req:0x8673751971e75cc0377d73b25bc4d890/src/http.Request -> Step
type Got source · line 15 · raw
@-A:Type -> Type
an effect's outcome on one connection: the value, or the line to log for a connection that is lost
Kept@-A:Type -> @value:A -> Got<A>
Dropped@-A:Type -> @line:String -> Got<A>
type Accept source · line 84 · raw
@-A:Type -> Type
what an accept with a deadline brought: a connection, nothing before the deadline, or a lost accept with its line (laws/FailedEffectsLoseConnection.bend)
Took@-A:Type -> @value:A -> Accept<A>
Idle@-A:Type -> Accept<A>
Missed@-A:Type -> @line:String -> Accept<A>
Definitions
def step.text source · line 22 · raw
@req:0x8673751971e75cc0377d73b25bc4d890/src/http.Request -> 0x8673751971e75cc0377d73b25bc4d890/src/http.Request
a request received as octets, as text: its method, target, header names and values and body each decoded as UTF-8 (laws/HandlerGetsRequestText.bend); a bad one keeps its reason
def step.of source · line 32 · raw
@req:0x8673751971e75cc0377d73b25bc4d890/src/http.Request -> Step
a bad request is answered 400 with its reason and never reaches the handler; a good one goes to the handler as it was parsed
def step.line source · line 40 · raw
@phase:String -> @why:String -> String
the line logged for a failed effect: ezhttp: <phase>: <why>
def step.got source · line 44 · raw
@-A:Type -> @phase:String -> @res:Result<&1, &1, Pair(U32, String), A> -> Got<A>
a failed accept or recv loses the connection instead of ending the server
def step.sent source · line 56 · raw
@res:Result<&1, &1, Pair(Pair(U32, String), List<&2, U32>), Unit> -> Got<Unit>
a failed send loses the connection too; the bytes it did not send are dropped
def step.bare source · line 70 · raw
@+method:String -> @+status:U32 -> Bool
whether a reply is written with its head only: a reply to HEAD, or a 204 or 304 (RFC 9110 §9.3.2, §15.3.5, §15.4.5)
def step.octets source · line 74 · raw
@req:0x8673751971e75cc0377d73b25bc4d890/src/http.Request -> String
the body octets of a request, as they arrived; none for a bad one
def step.missed source · line 90 · raw
@-A:Type -> @+why:String -> @late:Bool -> Accept<A>
a failed accept once it is known whether its deadline passed
def step.accepted source · line 98 · raw
@-A:Type -> @res:Result<&1, &1, Pair(U32, String), A> -> Accept<A>
an accept's outcome: ETIMEDOUT (110) is a deadline that passed
def step.clen source · line 109 · raw
@m:Maybe<&2, Nat> -> Nat
a Content-Length that reads, or none
def step.need.of source · line 118 · raw
@c:0x8673751971e75cc0377d73b25bc4d890/src/http.Cut -> Maybe<&2, Nat>
octets a request needs in all once its head has ended: the head, its blank line and the octets its Content-Length names (0 when it names none)
def step.need source · line 128 · raw
@+text:String -> Maybe<&2, Nat>
octets a request needs in all, none while its head has not ended