~/bend-docscommunity

src/wirespec.bend checks

raw source on the hub · import emerging-ezhttp@0.18.0.0/src/wirespec.bend as Wirespec

ezhttp/src/wirespec: what the client sends, when it has heard a whole answer, and what a failed socket call is reported as, pure. Kept apart from wire.bend (bend-kit-wire's effects) so the proof gate can import it. wire.bend and client.bend act on what is decided here.

An exchange's answer is a status on its first line, then text: "0" and the response received, or a non-zero status and the reason the exchange failed. SPEC.md HTTP-CLI lists what is guaranteed.

6 imports
import Base
import ./http.bend as Http
import ./url.bend as Url
import ./body.bend as Body
import ./pct.bend as Pct
import ./qs.bend as Qs

Types

type Exchange source · line 77 · raw

Data

what a request to a URL becomes: nothing when the URL did not parse, else the scheme (secure or not), host, port, method and request text the effect is given; the answer is read by that method (wire.read.next)

type Got source · line 180 · raw

Data

what has been received so far: its pieces, the newest first, and where the response stands (Http.hear)

type Read source · line 208 · raw

Data

after a read: read again with what has arrived, or answer

type Phase source · line 287 · raw

Data

where in an exchange a call failed

Definitions

def wire.ms.dflt source · line 19 · raw

U32

the deadline of an exchange with no timeout: 60 s, in milliseconds

def wire.ms.pick source · line 23 · raw

@ms:U32 -> @zero:Bool -> U32

a timeout once it is known whether it is 0

def wire.ms.at source · line 32 · raw

@+ms:U32 -> U32

a timeout as a deadline bend-kit-wire reads: 0 would be none there, so it is 1 ms

def wire.ms.of source · line 37 · raw

@m:Maybe<&2, U32> -> U32

the deadline every socket call of an exchange gets: the timeout it was made with, or the default (SPEC.md HTTP-CLI-1, 2)

def wire.late source · line 48 · raw

U32

the wire status for an exchange that ran out of time (curl's CURLE_OPERATION_TIMEDOUT)

def wire.why.of source · line 53 · raw

@why:String -> @late:Bool -> String

what a failed exchange is reported as: a timeout is marked, any other failure's reason is kept as it is

def wire.why source · line 61 · raw

@code:Maybe<&2, U32> -> @why:String -> String

a failed exchange's status and reason as the reason the client reports

def wire.timed_out source · line 69 · raw

@why:String -> Bool

whether a reported reason is a timeout

def wire.exchange.at source · line 82 · raw

@+method:String -> @+secure:Bool -> @+host:String -> @+port:U32 -> @path:String -> @headers:List<&2, 0x9aad1f0de4523b34b9bfb69ebb80e11a/src/http.Header> -> @body:String -> Exchange

the exchange once it is known whether the scheme wants TLS

def wire.exchange.method source · line 89 · raw

@ex:Exchange -> Maybe<&2, String>

the method an exchange is sent and read by, none when nothing is sent

def wire.exchange source · line 97 · raw

@method:String -> @l:0x9aad1f0de4523b34b9bfb69ebb80e11a/src/url.Loc -> @headers:List<&2, 0x9aad1f0de4523b34b9bfb69ebb80e11a/src/http.Header> -> @body:String -> Exchange

a request with this method, headers and body to a URL that came apart

def wire.exchange.octets source · line 108 · raw

@+method:String -> @l:0x9aad1f0de4523b34b9bfb69ebb80e11a/src/url.Loc -> @headers:List<&2, 0x9aad1f0de4523b34b9bfb69ebb80e11a/src/http.Header> -> @n:Nat -> Exchange

a request with n octets of body to a URL that came apart: the request text ends at the blank line, and the octets go after it as the tail (wire.tail)

def wire.exchange.body source · line 120 · raw

@method:String -> @l:0x9aad1f0de4523b34b9bfb69ebb80e11a/src/url.Loc -> @headers:List<&2, 0x9aad1f0de4523b34b9bfb69ebb80e11a/src/http.Header> -> @b:0x9aad1f0de4523b34b9bfb69ebb80e11a/src/body.Body -> Exchange

a request with this body to a URL that came apart: text inside the request text as UTF-8, octets after it (SPEC.md HTTP-CLI-10)

def wire.tail source · line 131 · raw

@b:0x9aad1f0de4523b34b9bfb69ebb80e11a/src/body.Body -> List<&2, U32>

the octets sent after the request text: an octet body's, else none

def wire.code.of source · line 143 · raw

@c:0x9aad1f0de4523b34b9bfb69ebb80e11a/src/http.Cut -> @raw:String -> Maybe<&2, U32>

an answer's status: the number on its first line, if it is one

def wire.code source · line 151 · raw

@+raw:String -> Maybe<&2, U32>

an answer's status line as a number

def wire.text.of source · line 155 · raw

@c:0x9aad1f0de4523b34b9bfb69ebb80e11a/src/http.Cut -> String

the text after an answer's first newline

def wire.text source · line 163 · raw

@raw:String -> String

the text after an answer's first newline

def wire.ok.of source · line 167 · raw

@m:Maybe<&2, U32> -> Bool

whether a status is success (0)

def wire.ok source · line 175 · raw

@raw:String -> Bool

whether an answer has status 0

def wire.joined source · line 184 · raw

@ps:List<&2, String> -> String

the text a list of pieces, newest first, stands for

def wire.join.go source · line 192 · raw

@ps:List<&2, String> -> @acc:String -> String

the pieces put together onto what follows them, each copied once

def wire.join source · line 200 · raw

@ps:List<&2, String> -> String

the text a list of pieces, newest first, stands for, built in one pass

def wire.got source · line 204 · raw

@+method:String -> @+ps:List<&2, String> -> Got

what has been received as these pieces, for a request with this method

def wire.read.whole source · line 213 · raw

@+ps:List<&2, String> -> @h:0x9aad1f0de4523b34b9bfb69ebb80e11a/src/http.Hear -> @done:Bool -> Read

everything received, once it is known whether it is a whole response

def wire.read.add source · line 221 · raw

@text:String -> @ps:List<&2, String> -> @+h:0x9aad1f0de4523b34b9bfb69ebb80e11a/src/http.Hear -> Read

a read that brought text, judged with where the response now stands

def wire.read.got source · line 225 · raw

@st:Got -> @+text:String -> @closed:Bool -> Read

a read that brought text, or found the connection closed

def wire.read.of source · line 233 · raw

@st:Got -> @+got:String -> @ok:Bool -> Read

a read's answer once it is known whether it succeeded

def wire.read.next source · line 243 · raw

@st:Got -> @+got:String -> Read

what to do after a read answered got, with what was received before it (SPEC.md HTTP-CLI-6)

def wire.spent source · line 247 · raw

String

the answer when the reads run out before the response ends

def wire.heard.of source · line 253 · raw

@+method:String -> @+raw:String -> @ok:Bool -> 0x9aad1f0de4523b34b9bfb69ebb80e11a/src/http.Reply

the response an exchange's answer holds, read by the request's method (SPEC.md HTTP-CLI-9); a failed exchange is torn with the reason it is reported with (wire.why)

def wire.phrase source · line 262 · raw

@raw:String -> String

the reason phrase of the response an exchange's answer holds (SPEC.md HTTP-CLI-11); a failed exchange's is read from its reason and not used

def wire.heard source · line 266 · raw

@+method:String -> @+raw:String -> 0x9aad1f0de4523b34b9bfb69ebb80e11a/src/http.Reply

the response an exchange's answer holds

def wire.payload.text source · line 272 · raw

@s:String -> @rest:String -> String

a request text's UTF-8 octets, one character each, onto the octets after it

def wire.payload source · line 281 · raw

@req:String -> @tail:List<&2, U32> -> String

the octets an exchange sends, one character each: the request text as UTF-8, then the body's tail

def wire.etimedout source · line 295 · raw

U32

the error number a call that ran out of time fails with (Linux ETIMEDOUT)

def wire.errnos source · line 299 · raw

List<&2, 0x9aad1f0de4523b34b9bfb69ebb80e11a/src/http.Phrase>

the Linux errno symbols this table names

def wire.errno.or source · line 316 · raw

@name:String -> String

a name from the table, or errno when it has none

def wire.errno.name source · line 324 · raw

@+n:U32 -> String

an error number's name (SPEC.md HTTP-CLI-14)

def wire.cause source · line 328 · raw

@+n:U32 -> String

an error number as a reason names it: <name> (<n>)

def wire.fail.late source · line 332 · raw

@p:Phase -> @host:String -> @+port:U32 -> @+ms:U32 -> @+n:U32 -> String

a call that ran out of time, by its phase

def wire.fail.other source · line 350 · raw

@p:Phase -> @host:String -> @+port:U32 -> @+n:U32 -> @why:String -> String

a call that failed for another reason, by its phase

def wire.fail.of source · line 367 · raw

@p:Phase -> @host:String -> @+port:U32 -> @+ms:U32 -> @+n:U32 -> @why:String -> @late:Bool -> String

a failure once it is known whether it ran out of time

def wire.fail source · line 377 · raw

@p:Phase -> @host:String -> @+port:U32 -> @+ms:U32 -> @+n:U32 -> @why:String -> String

the exchange's answer when a call in this phase failed with error number n and reason why, with deadline ms (SPEC.md HTTP-CLI-13)

def wire.utf8.wants source · line 385 · raw

@+b:U32 -> Nat

how many continuation octets a lead octet asks for (RFC 3629 §3); 0 for an octet that opens no sequence

def wire.utf8.cont source · line 392 · raw

@+b:U32 -> Bool

whether an octet continues a sequence (10xxxxxx)

def wire.utf8.lead source · line 397 · raw

@+b:U32 -> @+k:Nat -> Nat

the octet before k continuation octets: hold the k + 1 when it opens a sequence that wants more than k

def wire.utf8.back source · line 401 · raw

@+b:U32 -> @+k:Nat -> @more:Bool -> @rest:(@_:Unit -> Nat) -> Nat

one octet from the end: another continuation octet, or the one before them

def wire.utf8.open source · line 410 · raw

@r:List<&2, U32> -> @+k:Nat -> Nat

how many octets at the end of a list, given newest first, are a sequence still waiting for octets; k continuation octets have been passed

def wire.utf8.toks source · line 419 · raw

@bs:List<&2, U32> -> List<&2, 0x9aad1f0de4523b34b9bfb69ebb80e11a/src/qs.Tok>

octets as the pieces Qs.utf.dec reads

def wire.utf8.bytes source · line 427 · raw

@s:String -> List<&2, U32>

octets, one character each, as a list

def wire.utf8.feed source · line 436 · raw

@held:List<&2, U32> -> @got:String -> Pair(String, List<&2, U32>)

the octets held from before and a receive's octets: the text of all but a sequence still open at the end, and that sequence, held for the next

def wire.utf8.flush source · line 446 · raw

@held:List<&2, U32> -> String

what was held once the server has closed: decoded as it is