src/wirespec.bend checks
raw source on the hub · import ezhttp@0.25.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.
A failed exchange's answer is a non-zero status on its first line, then the reason (wire.fail); a successful one is the response's octets, which wire.bend keeps packed and packed.bend reads. What is guaranteed is under laws/, such as laws/RequestLineAndHost.bend.
5 imports
import Base import ./http.bend as Http import ./url.bend as Url import ./body.bend as Body import ./pct.bend as Pct
Types
type Exchange source · line 78 · 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 Read source · line 213 · raw
Data
after a read: read again from where the response now stands, or it has all been received
Again@hear:0x0b59049ea5717d6f2fd30293c7271ede/src/http.Hear -> Read
HeardRead
type Phase source · line 315 · 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 38 · raw
@m:Maybe<&2, U32> -> U32
the deadline every socket call of an exchange gets: the timeout it was made with, or the default (laws/DeadlineIsTimeout.bend, laws/TimeoutZeroIsOneMs.bend)
def wire.late source · line 49 · raw
U32
the wire status for an exchange that ran out of time (curl's CURLE_OPERATION_TIMEDOUT)
def wire.why.of source · line 54 · 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 62 · 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 70 · raw
@why:String -> Bool
whether a reported reason is a timeout
def wire.exchange.at source · line 83 · raw
@+method:String -> @+secure:Bool -> @+host:String -> @+port:U32 -> @path:String -> @headers:List<&2, 0x0b59049ea5717d6f2fd30293c7271ede/src/http.Header> -> @body:String -> Exchange
the exchange once it is known whether the scheme wants TLS
def wire.exchange.method source · line 96 · 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 104 · raw
@method:String -> @l:0x0b59049ea5717d6f2fd30293c7271ede/src/url.Loc -> @headers:List<&2, 0x0b59049ea5717d6f2fd30293c7271ede/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 119 · raw
@+method:String -> @l:0x0b59049ea5717d6f2fd30293c7271ede/src/url.Loc -> @headers:List<&2, 0x0b59049ea5717d6f2fd30293c7271ede/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 136 · raw
@method:String -> @l:0x0b59049ea5717d6f2fd30293c7271ede/src/url.Loc -> @headers:List<&2, 0x0b59049ea5717d6f2fd30293c7271ede/src/http.Header> -> @b:0x0b59049ea5717d6f2fd30293c7271ede/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 (laws/OctetBodiesSentUnchanged.bend)
def wire.code.of source · line 151 · raw
@c:0x0b59049ea5717d6f2fd30293c7271ede/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 159 · raw
@+raw:String -> Maybe<&2, U32>
an answer's status line as a number
def wire.text.of source · line 163 · raw
@c:0x0b59049ea5717d6f2fd30293c7271ede/src/http.Cut -> String
the text after an answer's first newline
def wire.text source · line 171 · raw
@raw:String -> String
the text after an answer's first newline
def wire.ok.of source · line 175 · raw
@m:Maybe<&2, U32> -> Bool
whether a status is success (0)
def wire.ok source · line 183 · raw
@raw:String -> Bool
whether an answer has status 0
def wire.joined source · line 187 · raw
@ps:List<&2, String> -> String
the text a list of pieces, newest first, stands for
def wire.join.go source · line 195 · raw
@ps:List<&2, String> -> @acc:String -> String
the pieces put together onto what follows them, each copied once
def wire.join source · line 203 · 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 208 · raw
@+method:String -> 0x0b59049ea5717d6f2fd30293c7271ede/src/http.Hear
where a response to a request with this method stands before anything has been received
def wire.read.done source · line 218 · raw
@+h:0x0b59049ea5717d6f2fd30293c7271ede/src/http.Hear -> @done:Bool -> Read
where the response stands after a read, judged
def wire.read.with source · line 226 · raw
@+h:0x0b59049ea5717d6f2fd30293c7271ede/src/http.Hear -> Read
where the response stands after a read, judged
def wire.read.got source · line 230 · raw
@h:0x0b59049ea5717d6f2fd30293c7271ede/src/http.Hear -> @+text:String -> @closed:Bool -> Read
a read that brought text, or found the connection closed
def wire.read.next source · line 239 · raw
@h:0x0b59049ea5717d6f2fd30293c7271ede/src/http.Hear -> @+text:String -> Read
what to do after a read brought this text, judged from where the response stood (laws/ReadsJudgedByCount.bend)
def wire.read.counted source · line 243 · raw
@+h:0x0b59049ea5717d6f2fd30293c7271ede/src/http.Hear -> @+m:Nat -> @counts:Bool -> Maybe<&2, Read>
a read of m octets judged by its count, when that is enough to judge it
def wire.read.count.at source · line 251 · raw
@+h:0x0b59049ea5717d6f2fd30293c7271ede/src/http.Hear -> @+m:Nat -> @closed:Bool -> Maybe<&2, Read>
a read of m octets: none is the close
def wire.read.count source · line 265 · raw
@+h:0x0b59049ea5717d6f2fd30293c7271ede/src/http.Hear -> @+m:Nat -> Maybe<&2, Read>
what to do after a read of m octets, when their count alone decides it; none when their text is needed (wire.read.next) (laws/ReadsJudgedByCount.bend)
def wire.spent source · line 269 · raw
String
the answer when the reads run out before the response ends
def wire.failed source · line 273 · raw
@+raw:String -> String
the reason a failed exchange's answer is reported with (wire.why)
def wire.heard.of source · line 279 · raw
@+method:String -> @+raw:String -> @ok:Bool -> 0x0b59049ea5717d6f2fd30293c7271ede/src/http.Reply
the response an exchange's answer holds, read by the request's method (laws/InterimResponsesSkipped.bend); a failed exchange is torn with the reason it is reported with (wire.why)
def wire.phrase source · line 289 · raw
@raw:String -> String
the reason phrase of the response an exchange's answer holds (laws/ReasonPhraseFromFinalHead.bend); a failed exchange's is read from its reason and not used
def wire.heard source · line 293 · raw
@+method:String -> @+raw:String -> 0x0b59049ea5717d6f2fd30293c7271ede/src/http.Reply
the response an exchange's answer holds
def wire.payload.text source · line 299 · 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 308 · 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 323 · raw
U32
the error number a call that ran out of time fails with (Linux ETIMEDOUT)
def wire.errnos source · line 327 · raw
List<&2, 0x0b59049ea5717d6f2fd30293c7271ede/src/http.Phrase>
the Linux errno symbols this table names
def wire.errno.or source · line 344 · raw
@name:String -> String
a name from the table, or errno when it has none
def wire.errno.name source · line 352 · raw
@+n:U32 -> String
an error number's name (laws/ErrnoNamesAreLinux.bend)
def wire.cause source · line 356 · raw
@+n:U32 -> String
an error number as a reason names it: <name> (<n>)
def wire.fail.resolve source · line 361 · 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 369 · 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 392 · 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 414 · 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 445 · 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 (laws/FailuresReportedByPhase.bend).
Trusted, not proved: bend-kit-wire and bend-kit-dns report a failed call
as the platform's errno number and its strerror text, except that
tls.connect reports a failed handshake as EPROTO with OpenSSL's verify
reason (or TLS handshake failed), and lookup.all reports a name that
does not resolve as ENOENT, a temporary failure as EAGAIN, running out of
memory as ENOMEM and any other getaddrinfo failure as EIO; a call whose
deadline passes fails with ETIMEDOUT and no other call does. The names
laws/ErrnoNamesAreLinux.bend gives are Linux's numbering. It is foreign C
and JS reading errno, getaddrinfo and OpenSSL, which no law reaches. What
each number is named and what a failed exchange is reported as are proved
(laws/FailuresReportedByPhase.bend, laws/ErrnoNamesAreLinux.bend), and
that the reason reaches Client.Err unchanged
(laws/TimeoutsReadAsTimedOut.bend, laws/InterimResponsesSkipped.bend).