src/wirespec.bend checks
raw source on the hub · import emerging-ezhttp@0.20.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)
NoUrl@why:String -> Exchange
Exchange@secure:Bool -> @host:String -> @port:U32 -> @method:String -> @req:String -> Exchange
type Got source · line 168 · raw
Data
what has been received so far: its pieces, the newest first, and where the response stands (Http.hear)
Got@pieces:List<&2, String> -> @hear:0xdc8b9e3a3b68c4b632d5e290f8608324/src/http.Hear -> Got
type Read source · line 196 · raw
Data
after a read: read again with what has arrived, or answer
Again@acc:Got -> Read
Heard@answer:String -> Read
type Phase source · line 275 · raw
Data
where in an exchange a call failed
ResolvePhase
ConnectPhase
HandshakePhase
SendPhase
ReceivePhase
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, 0xdc8b9e3a3b68c4b632d5e290f8608324/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:0xdc8b9e3a3b68c4b632d5e290f8608324/src/url.Loc -> @headers:List<&2, 0xdc8b9e3a3b68c4b632d5e290f8608324/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:0xdc8b9e3a3b68c4b632d5e290f8608324/src/url.Loc -> @headers:List<&2, 0xdc8b9e3a3b68c4b632d5e290f8608324/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
def wire.exchange.body source · line 120 · raw
@method:String -> @l:0xdc8b9e3a3b68c4b632d5e290f8608324/src/url.Loc -> @headers:List<&2, 0xdc8b9e3a3b68c4b632d5e290f8608324/src/http.Header> -> @b:0xdc8b9e3a3b68c4b632d5e290f8608324/src/body.Shape -> Exchange
a request with a body of this shape to a URL that came apart: text inside the request text as UTF-8, octets after it (SPEC.md HTTP-CLI-10)
def wire.code.of source · line 131 · raw
@c:0xdc8b9e3a3b68c4b632d5e290f8608324/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 139 · raw
@+raw:String -> Maybe<&2, U32>
an answer's status line as a number
def wire.text.of source · line 143 · raw
@c:0xdc8b9e3a3b68c4b632d5e290f8608324/src/http.Cut -> String
the text after an answer's first newline
def wire.text source · line 151 · raw
@raw:String -> String
the text after an answer's first newline
def wire.ok.of source · line 155 · raw
@m:Maybe<&2, U32> -> Bool
whether a status is success (0)
def wire.ok source · line 163 · raw
@raw:String -> Bool
whether an answer has status 0
def wire.joined source · line 172 · raw
@ps:List<&2, String> -> String
the text a list of pieces, newest first, stands for
def wire.join.go source · line 180 · raw
@ps:List<&2, String> -> @acc:String -> String
the pieces put together onto what follows them, each copied once
def wire.join source · line 188 · 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 192 · 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 201 · raw
@+ps:List<&2, String> -> @h:0xdc8b9e3a3b68c4b632d5e290f8608324/src/http.Hear -> @done:Bool -> Read
everything received, once it is known whether it is a whole response
def wire.read.add source · line 209 · raw
@text:String -> @ps:List<&2, String> -> @+h:0xdc8b9e3a3b68c4b632d5e290f8608324/src/http.Hear -> Read
a read that brought text, judged with where the response now stands
def wire.read.got source · line 213 · raw
@st:Got -> @+text:String -> @closed:Bool -> Read
a read that brought text, or found the connection closed
def wire.read.of source · line 221 · 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 231 · 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 235 · raw
String
the answer when the reads run out before the response ends
def wire.heard.of source · line 241 · raw
@+method:String -> @+raw:String -> @ok:Bool -> 0xdc8b9e3a3b68c4b632d5e290f8608324/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 250 · 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 254 · raw
@+method:String -> @+raw:String -> 0xdc8b9e3a3b68c4b632d5e290f8608324/src/http.Reply
the response an exchange's answer holds
def wire.payload.text source · line 260 · 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 269 · raw
@req:String -> String
the octets of a request text, one character each: its UTF-8 (the body's octets go after them)
def wire.etimedout source · line 283 · raw
U32
the error number a call that ran out of time fails with (Linux ETIMEDOUT)
def wire.errnos source · line 287 · raw
List<&2, 0xdc8b9e3a3b68c4b632d5e290f8608324/src/http.Phrase>
the Linux errno symbols this table names
def wire.errno.or source · line 304 · raw
@name:String -> String
a name from the table, or errno when it has none
def wire.errno.name source · line 312 · raw
@+n:U32 -> String
an error number's name (SPEC.md HTTP-CLI-14)
def wire.cause source · line 316 · raw
@+n:U32 -> String
an error number as a reason names it: <name> (<n>)
def wire.fail.resolve source · line 321 · raw
@host:String -> @+n:U32 -> @none:Bool -> String
a resolve's failure: bend-kit-dns reports a name with no address as ENOENT, whose name would read as a missing file, so only the host is named
def wire.fail.late source · line 329 · 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 347 · 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 364 · 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 374 · 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)