src/http.bend checks
raw source on the hub · import emerging-ezhttp@0.19.0.0/src/http.bend as Http
ezhttp/src/http: HTTP/1.1 message text for client and server — request and response formatting/parsing — with no sockets. Semantics follow RFC 9110; message syntax and framing follow RFC 9112. TLS is outside this module.
2 imports
import Base import ./body.bend as Body
Types
type Cut source · line 8 · raw
Data
a string divided at the first occurrence of a pattern, or not divided at all
NoCutCut
Cut@before:String -> @after:String -> Cut
type Header source · line 13 · raw
Data
one header field name and value (RFC 9110 §5 / RFC 9112 §5)
H@name:String -> @value:String -> Header
type Reply source · line 17 · raw
Data
what a response turned out to be: status, headers, framed body — or why not
Torn@why:String -> Reply
Reply@status:U32 -> @headers:List<&2, Header> -> @body:String -> Reply
type Next source · line 253 · raw
Data
the next scan step, or why this chunk header is not usable
StopNext
Go@cut:Cut -> Next
Reject@why:String -> Next
type Field source · line 466 · raw
Data
the fields a request names: the ones ezhttp writes a default for, the ones it always computes, and every other (SPEC.md HTTP-CLI-8)
FHostField
FAgentField
FAcceptField
FConnField
FClenField
FOtherField
type Request source · line 863 · raw
Data
a request that came apart, or the reason it would not (RFC 9112 §3)
Bad@why:String -> Request
Request@method:String -> @target:String -> @headers:List<&2, Header> -> @body:String -> Request
type Phrase source · line 869 · raw
Data
a status code and its reason-phrase
P@code:U32 -> @text:String -> Phrase
type Frame source · line 1092 · raw
Data
how a response's body is framed
BareFrame
Sized@n:Nat -> Frame
ChunkedFrame
ClosedFrame
type Skip source · line 1317 · raw
Data
bytes of UTF-8 walked off the front of a string: all of it, with this many still owed, or a stop at the first character that does not fit in what was left, with what was left and the text from that character on
Short@owed:Nat -> Skip
Over@left:Nat -> @rest:String -> Skip
type Walk source · line 1343 · raw
Data
where a chunked body's walk stands: ended; waiting at a chunk header (or the
last chunk's trailer) that has not all arrived; inside a chunk's data with
octets still owed; or at the end of a chunk's data, at what should be its
CRLF. fuel is what chunks.ended would have left there.
EndedWalk
Hold@fuel:Nat -> @rest:String -> Walk
Owed@fuel:Nat -> @owed:Nat -> Walk
Tail@fuel:Nat -> @left:Nat -> @rest:String -> Walk
type Hear source · line 1442 · raw
Data
where a response stands: no final head yet (with the text from the head being read on, and the fuel whole.go would have there); no body, so whole; framed by the close, so never whole; sized, with the octets that have arrived; or chunked, with its walk
Heads@fuel:Nat -> @asked:Bool -> @raw:String -> Hear
WholeHear
NeverHear
Count@n:Nat -> @have:Nat -> Hear
Walking@w:Walk -> Hear
Definitions
def first source · line 22 · raw
@ps:List<&2, String> -> String
the first of a list of pieces, "" when there are none
def second source · line 30 · raw
@ps:List<&2, String> -> String
the second of a list of pieces, "" when there is no second
def divide.push source · line 38 · raw
@h:Char -> @r:Cut -> Cut
one char of the divide, put back on the front of what the rest found
def divide.step source · line 46 · raw
@here:Bool -> @h:Char -> @t:String -> @n:Nat -> @rest:(@_:Unit -> Cut) -> Cut
one step of the walk; rest is a thunk so Bool.pick does not force recursion
def divide.go source · line 55 · raw
@s:String -> @+pat:String -> @+n:Nat -> Cut
the walk: stop at the first hit
def divide source · line 64 · raw
@s:String -> @+pat:String -> Cut
a string in two halves around the first occurrence of a pattern
def hex.of source · line 68 · raw
@+u:U32 -> U32
the value of one hex digit's code point, or 16 when it is not one
def hex.val source · line 75 · raw
@c:Char -> U32
the value of one hex digit, or 16 when the char is not one
def hex.step source · line 79 · raw
@done:Bool -> @acc:Nat -> @rest:(@_:Unit -> Nat) -> Nat
one step of the hex read
def hex.go source · line 87 · raw
@s:String -> @+acc:Nat -> Nat
the hex digits at the front of a string, read until one is not a digit
def hexlen source · line 97 · raw
@s:String -> Nat
chunk-size from a chunk header (RFC 9112 §7.1); extensions after ; ignored
def hex.digit source · line 101 · raw
@c:Char -> Bool
whether a character is a hex digit
def hex.rest source · line 105 · raw
@token:String -> @good:Bool -> Bool
the rest of a hex token once the first digit is known
def hex.well source · line 115 · raw
@token:String -> Bool
a chunk-size token is one or more hex digits (RFC 9112 §7.1)
def chunks.token source · line 123 · raw
@before:String -> String
the chunk-size token, extensions after ; removed
def utf8.width source · line 129 · raw
@+u:U32 -> Nat
octets one code point takes in UTF-8, for a text written onto the wire (RFC 3629 §3). Content-Length counts octets (RFC 9110 §8.6); a Bend String counts code points.
def utf8.len source · line 135 · raw
@s:String -> Nat
how many octets of UTF-8 a text is
def octs.width source · line 146 · raw
@+_u:U32 -> Nat
octets one received character stands for: one
def octs.len source · line 150 · raw
@s:String -> Nat
how many octets a received text is
def octs.take.step source · line 158 · raw
@short:Bool -> @h:Char -> @rest:(@_:Unit -> String) -> String
one step of the take
def octs.take source · line 166 · raw
@s:String -> @+n:Nat -> String
the front of a string that is this many bytes of UTF-8
def octs.drop.step source · line 175 · raw
@short:Bool -> @h:Char -> @t:String -> @rest:(@_:Unit -> String) -> String
one step of the drop
def octs.drop source · line 184 · raw
@s:String -> @+n:Nat -> String
the rest of a string after this many bytes of UTF-8
def digits.val.of source · line 193 · raw
@+u:U32 -> U32
a decimal digit's value, or 10 when the character is not a digit
def digits.val source · line 197 · raw
@c:Char -> U32
a decimal digit's value, or 10 when the character is not a digit
def digits.step source · line 201 · raw
@ok:Bool -> @next:(@_:Unit -> Maybe<&2, Nat>) -> Maybe<&2, Nat>
accept one digit and keep reading, or stop when it is not a digit
def digits.go source · line 209 · raw
@s:String -> @+acc:Nat -> @left:Nat -> Maybe<&2, Nat>
read a decimal token without building Base's Nat.read ceiling
def digits.read source · line 221 · raw
@s:String -> Maybe<&2, Nat>
a short decimal (Content-Length, max-age). Empty is none. At most 9 digits.
def octs.has.step source · line 230 · raw
@short:Bool -> @rest:(@_:Unit -> Bool) -> Bool
one step of the count: a character wider than what is still asked for means the string is longer
def octs.has source · line 239 · raw
@s:String -> @+n:Nat -> Bool
whether a string is at least this many bytes of UTF-8, walking no further than that many (octs.len walks all of it)
def chunks.ready source · line 248 · raw
@+after:String -> @+n:Nat -> Bool
a non-zero chunk has its data and the following CRLF
def chunks.next.of source · line 259 · raw
@zero:Bool -> @ready:Bool -> @+after:String -> @+n:Nat -> Next
one chunk header: reject non-hex sizes, stop on the 0 chunk, else continue
def chunks.next.hex source · line 269 · raw
@+before:String -> @+after:String -> @ok:Bool -> Next
hex check, then the length
def chunks.next source · line 278 · raw
@+before:String -> @+after:String -> Next
classify one chunk header (RFC 9112 §7.1)
def chunks.scan.step source · line 282 · raw
@step:Next -> @rest:(@_:Cut -> Maybe<&2, String>) -> Maybe<&2, String>
apply one scan step
def chunks.scan source · line 293 · raw
@fuel:Nat -> @c:Cut -> Maybe<&2, String>
None when every chunk size is hex and the 0 chunk is reached
def chunks.more source · line 303 · raw
@+n:Nat -> @+after:String -> @rest:(@_:Unit -> String) -> @zero:Bool -> String
a zero chunk ends the body; anything after it is a trailer (RFC 9112 §7.1)
def chunks source · line 313 · raw
@fuel:Nat -> @c:Cut -> String
a chunked body put back together (RFC 9112 §7.1)
def dechunk source · line 326 · raw
@+s:String -> String
a Transfer-Encoding: chunked body as the octets it stands for
def head.hit source · line 331 · raw
@h:String -> @+name:String -> Bool
whether a head line names this header (field names are case-insensitive: RFC 9110 §5.1)
def head.pick source · line 335 · raw
@hit:Bool -> @h:String -> @name:String -> @rest:String -> String
this line's value when it is the header asked for
def head.go source · line 343 · raw
@ls:List<&2, String> -> @+name:String -> String
the value a head gave a header, "" when it gave none
def head.value source · line 351 · raw
@h:String -> @name:String -> String
this line's trimmed field value
def head.values.cons source · line 355 · raw
@hit:Bool -> @value:String -> @rest:(@_:Unit -> List<&2, String>) -> List<&2, String>
cons a value when the line is the header asked for
def head.values source · line 364 · raw
@ls:List<&2, String> -> @+name:String -> List<&2, String>
every value a head gave a header, in order (RFC 9112 §6.3 lists Content-Length)
def field.folded source · line 373 · raw
@+value:String -> Bool
a field value still holding a line break is obs-fold, which we refuse
def field.keep source · line 377 · raw
@name:String -> @+value:String -> @folded:Bool -> Maybe<&2, Header>
a trimmed field value, or none when it still contains obs-fold
def head.from_kept source · line 385 · raw
@before:String -> @+after:String -> Maybe<&2, Header>
name and trimmed value from a cut at the first colon
def head.from_cut source · line 390 · raw
@c:Cut -> Maybe<&2, Header>
one header line as a Header, or none when it has no colon
def head.line source · line 398 · raw
@h:String -> Maybe<&2, Header>
one header line as a Header, or none when it has no colon
def head.cons source · line 402 · raw
@m:Maybe<&2, Header> -> @rest:List<&2, Header> -> List<&2, Header>
prepend a parsed header when present
def head.list source · line 410 · raw
@ls:List<&2, String> -> List<&2, Header>
header lines after the status line as a list of fields
def header.line source · line 418 · raw
@h:Header -> String
one request header line
def headers.find.pick source · line 424 · raw
@value:String -> @hit:Bool -> @rest:(@_:Unit -> String) -> String
the value when this field is the one asked for
def headers.find.go source · line 432 · raw
@hs:List<&2, Header> -> @+name:String -> String
case-insensitive field lookup (RFC 9110 §5.1)
def headers.find source · line 441 · raw
@hs:List<&2, Header> -> @+name:String -> String
the value of a field, "" when it is absent
def headers.lines source · line 445 · raw
@hs:List<&2, Header> -> String
extra headers rendered in order
def clen.field source · line 453 · raw
@+n:Nat -> @empty:Bool -> List<&2, Header>
the Content-Length field when the body is not empty (RFC 9110 §8.6)
def clen.line source · line 461 · raw
@+n:Nat -> @empty:Bool -> String
Content-Length line when the body is not empty (RFC 9110 §8.6)
def field.rank source · line 475 · raw
@f:Field -> U32
a field's place in the order above
def field.same source · line 491 · raw
@a:Field -> @b:Field -> Bool
whether two fields are the same one
def field.of.clen source · line 495 · raw
@hit:Bool -> Field
a lower-case name that is not content-length
def field.of.conn source · line 503 · raw
@hit:Bool -> @+l:String -> Field
a lower-case name that is not connection
def field.of.accept source · line 511 · raw
@hit:Bool -> @+l:String -> Field
a lower-case name that is not accept
def field.of.agent source · line 519 · raw
@hit:Bool -> @+l:String -> Field
a lower-case name that is not user-agent
def field.of.host source · line 527 · raw
@hit:Bool -> @+l:String -> Field
a lower-case name that is not host
def field.of source · line 535 · raw
@+l:String -> Field
the field a lower-case name names
def field.name source · line 539 · raw
@name:String -> Field
the field a name names, compared case-insensitively (RFC 9110 §5.1)
def header.field source · line 543 · raw
@h:Header -> Field
the field a header line names
def fields.put source · line 549 · raw
@keep:Bool -> @h:Header -> @rest:List<&2, Header> -> List<&2, Header>
keep a header in front of the rest, or not
def fields.of source · line 558 · raw
@+f:Field -> @hs:List<&2, Header> -> List<&2, Header>
the headers that name one field, in order
def fields.or source · line 566 · raw
@given:List<&2, Header> -> @dflt:List<&2, Header> -> List<&2, Header>
the caller's fields of a name, or the default when it gave none
def request.fields.n source · line 580 · raw
@host:String -> @+hs:List<&2, Header> -> @+n:Nat -> List<&2, Header>
a request's header fields for a body of n octets: Host, User-Agent and Accept (the caller's, or the default), Connection: close, the caller's other fields, Content-Length. A caller's Connection or Content-Length is not sent: Connection: close lets the connection end frame the body when no Content-Length / chunked framing applies (RFC 9112 §9.6 / §6.3), and the body's length is computed.
def request.fields source · line 592 · raw
@host:String -> @+hs:List<&2, Header> -> @+body:String -> List<&2, Header>
a request's header fields for a text body: the fields for its UTF-8 octets
def request source · line 598 · raw
@method:String -> @host:String -> @path:String -> @headers:List<&2, Header> -> @+body:String -> String
a request-line and headers (RFC 9112 §3, §5). Absolute-path request-target (RFC 9112 §3.2.1); the fields are request.fields'.
def port.dflt source · line 607 · raw
@secure:Bool -> U32
the port a scheme implies: 443 for a secure one, 80 otherwise (RFC 9110 §4.2.1, §4.2.2)
def authority.of source · line 615 · raw
@host:String -> @+port:U32 -> @dflt:Bool -> String
the Host field value once it is known whether the port is the default
def authority source · line 624 · raw
@secure:Bool -> @host:String -> @+port:U32 -> String
the Host field value: the host, and the port after a colon unless it is the scheme's default (RFC 9110 §7.2)
def request.at source · line 628 · raw
@method:String -> @secure:Bool -> @host:String -> @port:U32 -> @path:String -> @headers:List<&2, Header> -> @body:String -> String
the request a client sends to host and port, over TLS when secure
def request.head source · line 634 · raw
@method:String -> @host:String -> @path:String -> @headers:List<&2, Header> -> @+n:Nat -> String
the request text for a body of n octets that is sent after it as its own octets: the request line, the fields for n octets, and the blank line
def request.head.at source · line 641 · raw
@method:String -> @secure:Bool -> @host:String -> @port:U32 -> @path:String -> @headers:List<&2, Header> -> @n:Nat -> String
the request text a client sends to host and port ahead of n octets
def get_req source · line 646 · raw
@host:String -> @path:String -> @headers:List<&2, Header> -> String
GET with optional headers
def head_req source · line 650 · raw
@host:String -> @path:String -> @headers:List<&2, Header> -> String
HEAD with optional headers (RFC 9110 §9.3.2): same as GET, no body
def post_req source · line 654 · raw
@host:String -> @path:String -> @headers:List<&2, Header> -> @body:String -> String
POST with body and optional headers
def put_req source · line 659 · raw
@host:String -> @path:String -> @headers:List<&2, Header> -> @body:String -> String
PUT with body and optional headers (RFC 9110 §9.3.4)
def delete_req source · line 664 · raw
@host:String -> @path:String -> @headers:List<&2, Header> -> @body:String -> String
DELETE with body and optional headers (RFC 9110 §9.3.5)
def options_req source · line 669 · raw
@host:String -> @path:String -> @headers:List<&2, Header> -> String
OPTIONS with optional headers (RFC 9110 §9.3.7). No request body.
def method.safe source · line 673 · raw
@+method:String -> Bool
GET, HEAD, and OPTIONS are safe (RFC 9110 §9.2.1). Tokens are case-sensitive.
def method.idempotent source · line 678 · raw
@+method:String -> Bool
safe methods, plus PUT and DELETE, are idempotent (RFC 9110 §9.2.2)
def token.ok.step source · line 683 · raw
@space:Bool -> @rest:(@_:Unit -> Bool) -> Bool
the rest of a token once this character is known
def token.ok source · line 691 · raw
@s:String -> Bool
a bearer token has no whitespace (RFC 6750 §2.1)
def target.origin source · line 699 · raw
@path:String -> Bool
origin-form request-target: absolute-path, optional query (RFC 9112 §3.2.1)
def target.asterisk source · line 703 · raw
@method:String -> @star:Bool -> Bool
asterisk-form is only * and only for OPTIONS (RFC 9112 §3.2.4)
def target.form source · line 711 · raw
@method:String -> @path:String -> @absolute:Bool -> Bool
origin-form, or OPTIONS asterisk-form
def parse.short source · line 719 · raw
@status:U32 -> @headers:List<&2, Header> -> @n:Nat -> @body:String -> @short:Bool -> Reply
a body against the length its head promised
def parse.clen source · line 728 · raw
@status:U32 -> @headers:List<&2, Header> -> @+n:Nat -> @+body:String -> Reply
a body framed by Content-Length (RFC 9110 §8.6 / RFC 9112 §6.3)
def parse.len source · line 733 · raw
@status:U32 -> @headers:List<&2, Header> -> @m:Maybe<&2, Nat> -> @body:String -> Reply
Content-Length when present; else the rest of the connection is the body
def clen.agree.step source · line 742 · raw
@same:Bool -> @rest:(@_:Unit -> Bool) -> Bool
every Content-Length text equals the first
def clen.agree.go source · line 750 · raw
@rest:List<&2, String> -> @+h:String -> Bool
the tail of a Content-Length list against the first value
def clen.agree source · line 758 · raw
@vs:List<&2, String> -> Bool
duplicate Content-Length fields must be the same digits (RFC 9112 §6.3)
def clen.any source · line 766 · raw
@vs:List<&2, String> -> Bool
whether any Content-Length field was present
def parse.chunked source · line 774 · raw
@status:U32 -> @headers:List<&2, Header> -> @body:String -> @bad:Maybe<&2, String> -> Reply
a chunked body, or why the chunk framing was rejected
def parse.chunks source · line 783 · raw
@status:U32 -> @headers:List<&2, Header> -> @+body:String -> Reply
scan chunk sizes, then decode when they are hex and closed by 0
def parse.te.clash source · line 788 · raw
@status:U32 -> @headers:List<&2, Header> -> @body:String -> @present:Bool -> Reply
Transfer-Encoding together with Content-Length is a bad message
def parse.te source · line 797 · raw
@status:U32 -> @headers:List<&2, Header> -> @+lens:List<&2, String> -> @+body:String -> @chunked:Bool -> Reply
chunked framing, or Content-Length, or the rest of the connection
def parse.agree source · line 806 · raw
@status:U32 -> @headers:List<&2, Header> -> @te:String -> @+lens:List<&2, String> -> @body:String -> @ok:Bool -> Reply
disagreeing Content-Length values are torn before framing
def parse.frame source · line 816 · raw
@status:U32 -> @headers:List<&2, Header> -> @te:String -> @+lens:List<&2, String> -> @body:String -> Reply
the headers that decide the framing (RFC 9112 §6.3)
def parse.status source · line 821 · raw
@m:Maybe<&2, U32> -> @+ls:List<&2, String> -> @body:String -> Reply
a head whose status line has been read (RFC 9112 §4)
def status.of source · line 832 · raw
@ls:List<&2, String> -> Maybe<&2, U32>
the status code a head's first line names, if it names one (RFC 9112 §4)
def parse.head source · line 836 · raw
@+ls:List<&2, String> -> @body:String -> Reply
the head's lines, with the status line read off the first
def parse.cut source · line 841 · raw
@c:Cut -> Reply
a response divided into its head and everything after the blank line (RFC 9112 §2.1: header section ends at empty line)
def parse source · line 849 · raw
@raw:String -> Reply
the status, headers, and body of a raw response
def show source · line 853 · raw
@r:Reply -> String
a parsed response on one line, for a test to read
def reasons source · line 873 · raw
List<&2, Phrase>
the reason-phrases RFC 9110 §15 names (RFC 6585 §4 for 429)
def reason.pick source · line 887 · raw
@text:String -> @hit:Bool -> @rest:(@_:Unit -> String) -> String
this phrase when its code is the one asked for, else the rest's
def reason.in source · line 895 · raw
@ps:List<&2, Phrase> -> @+code:U32 -> String
the phrase a list gives a code, "" when it gives none
def reason source · line 903 · raw
@+code:U32 -> String
the reason-phrase for a status code (RFC 9112 §4); "" for one not listed
def respond source · line 908 · raw
@+status:U32 -> @headers:List<&2, Header> -> @+body:String -> String
status-line + headers + body (RFC 9112 §4, §5). Connection: close ends the exchange after one response.
def status.nocontent source · line 918 · raw
@+code:U32 -> Bool
204 and 304 are terminated by the header section (RFC 9110 §15.3.5, §15.4.5)
def respond.of.body source · line 922 · raw
@+status:U32 -> @headers:List<&2, Header> -> @body:String -> @drop:Bool -> String
drop a 204/304 body; any other status keeps it
def respond.of source · line 931 · raw
@r:Reply -> String
format a structured Reply as a response message
def reply.for.pick source · line 939 · raw
@reply:Reply -> @head:Bool -> Reply
HEAD carries no message body; any other method keeps the body (RFC 9110 §9.3.2)
def reply.for source · line 949 · raw
@method:String -> @reply:Reply -> Reply
drop a HEAD response body before it is written
def method.of source · line 953 · raw
@req:Request -> String
the method token, or "" when the request did not parse
def ask.short source · line 961 · raw
@method:String -> @target:String -> @headers:List<&2, Header> -> @n:Nat -> @body:String -> @short:Bool -> Request
request body against Content-Length
def ask.clen source · line 970 · raw
@method:String -> @target:String -> @headers:List<&2, Header> -> @+n:Nat -> @+body:String -> Request
a request body framed by Content-Length (RFC 9110 §8.6 / RFC 9112 §6.3)
def ask.len source · line 975 · raw
@method:String -> @target:String -> @headers:List<&2, Header> -> @m:Maybe<&2, Nat> -> @body:String -> Request
Content-Length when present; else the rest of the connection is the body
def ask.chunked source · line 984 · raw
@method:String -> @target:String -> @headers:List<&2, Header> -> @body:String -> @bad:Maybe<&2, String> -> Request
a chunked request body, or why the chunk framing was rejected
def ask.chunks source · line 993 · raw
@method:String -> @target:String -> @headers:List<&2, Header> -> @+body:String -> Request
scan chunk sizes, then decode when they are hex and closed by 0
def ask.te.clash source · line 999 · raw
@method:String -> @target:String -> @headers:List<&2, Header> -> @body:String -> @present:Bool -> Request
Transfer-Encoding together with Content-Length is a bad request
def ask.te source · line 1008 · raw
@method:String -> @target:String -> @headers:List<&2, Header> -> @+lens:List<&2, String> -> @+body:String -> @chunked:Bool -> Request
chunked framing, or Content-Length, or the rest of the connection
def ask.agree source · line 1017 · raw
@method:String -> @target:String -> @headers:List<&2, Header> -> @te:String -> @+lens:List<&2, String> -> @body:String -> @ok:Bool -> Request
disagreeing Content-Length values are bad before framing
def ask.frame source · line 1027 · raw
@method:String -> @target:String -> @headers:List<&2, Header> -> @te:String -> @+lens:List<&2, String> -> @body:String -> Request
the headers that decide request framing (RFC 9112 §6.3)
def ask.origin source · line 1032 · raw
@method:String -> @target:String -> @+ls:List<&2, String> -> @body:String -> @ok:Bool -> Request
origin-form, or a bad request when the target is not an absolute-path
def ask.line source · line 1043 · raw
@+method:String -> @+target:String -> @+ls:List<&2, String> -> @body:String -> Request
request-line: method SP request-target SP HTTP-version (RFC 9112 §3)
def ask.parts source · line 1049 · raw
@ps:List<&2, String> -> @+ls:List<&2, String> -> @body:String -> Request
three fields of the request-line, or torn
def ask.head source · line 1062 · raw
@+ls:List<&2, String> -> @body:String -> Request
the head's lines, with the request-line read off the first
def ask.cut source · line 1070 · raw
@c:Cut -> Request
a request divided into its head and everything after the blank line
def ask source · line 1078 · raw
@raw:String -> Request
the method, target, headers, and body of a raw request
def ask.show source · line 1082 · raw
@r:Request -> String
a parsed request on one line, for a test to read
def status.bare source · line 1100 · raw
@m:Maybe<&2, U32> -> Bool
204 and 304 carry no body; a status line that did not parse is framed by its headers
def status.interim source · line 1109 · raw
@m:Maybe<&2, U32> -> Bool
a 1xx status is an interim response (RFC 9110 §15.2); a status line that did not parse is not
def frame.sized source · line 1117 · raw
@m:Maybe<&2, Nat> -> Frame
a Content-Length that reads as a number, or the close when none does
def frame.agree source · line 1125 · raw
@+lens:List<&2, String> -> @ok:Bool -> Frame
Content-Length values that agree frame the body; any others leave the close
def frame.te source · line 1133 · raw
@+lens:List<&2, String> -> @chunked:Bool -> Frame
chunked framing wins over Content-Length (RFC 9112 §6.3 item 4)
def frame source · line 1142 · raw
@bare:Bool -> @te:String -> @+lens:List<&2, String> -> Frame
the framing of a response: none when bare (a reply to HEAD, a 204 or a 304), else Transfer-Encoding chunked, else Content-Length, else the close
def chunks.trailer source · line 1150 · raw
@+after:String -> Bool
a zero chunk's trailer section has ended: at once, or after its fields
def chunks.ended.data source · line 1154 · raw
@+after:String -> @+n:Nat -> @ready:Bool -> @rest:(@_:Cut -> Bool) -> Bool
a chunk that has all arrived: on to the next chunk header, else not yet
def chunks.ended.size source · line 1163 · raw
@+after:String -> @+n:Nat -> @zero:Bool -> @rest:(@_:Cut -> Bool) -> Bool
a chunk of size n: the last one when n is 0
def chunks.ended.hex source · line 1172 · raw
@+before:String -> @+after:String -> @ok:Bool -> @rest:(@_:Cut -> Bool) -> Bool
a chunk header: a size that is not hex ends the read (the parse rejects it)
def chunks.ended.at source · line 1182 · raw
@c:Cut -> @rest:(@_:Cut -> Bool) -> Bool
a chunk header that has arrived, or not yet
def chunks.ended source · line 1190 · raw
@fuel:Nat -> @c:Cut -> Bool
whether a chunked body has reached the end of its last chunk
def whole.of source · line 1198 · raw
@f:Frame -> @+body:String -> Bool
whether a body has all arrived under its framing
def whole.step source · line 1211 · raw
@asked:Bool -> @+ls:List<&2, String> -> @+after:String -> @interim:Bool -> @rest:(@_:Cut -> Bool) -> Bool
a head that is interim: whole when what follows is; else whole under the framing it gives
def whole.at source · line 1222 · raw
@asked:Bool -> @c:Cut -> @rest:(@_:Cut -> Bool) -> Bool
a response whose head has ended, or not yet
def whole.go source · line 1231 · raw
@fuel:Nat -> @+asked:Bool -> @c:Cut -> Bool
the heads in turn, at most fuel of them
def whole source · line 1241 · raw
@+method:String -> @+raw:String -> Bool
whether the text received so far is a whole response to a request with this method (RFC 9112 §6.3), interim 1xx heads read past (RFC 9110 §15.2); a response framed by the close never is
def status.empty source · line 1248 · raw
@+m:Maybe<&2, U32> -> Bool
a 1xx, 204 or 304 response has no body (RFC 9110 §6.4.1)
def interim.skip source · line 1252 · raw
@m:Maybe<&2, U32> -> @after:String -> Bool
an interim head is skipped when more text follows it
def parse.to.bare source · line 1256 · raw
@m:Maybe<&2, U32> -> @ls:List<&2, String> -> Reply
the final head with no body: its status and fields, an empty body
def parse.to.final source · line 1264 · raw
@m:Maybe<&2, U32> -> @+ls:List<&2, String> -> @after:String -> @bare:Bool -> Reply
the final head: with no body, or framed as parse frames it
def parse.to.step source · line 1273 · raw
@head:Bool -> @+ls:List<&2, String> -> @+m:Maybe<&2, U32> -> @+after:String -> @skip:Bool -> @rest:(@_:Cut -> Reply) -> Reply
an interim head is skipped, any other is the final one
def parse.to.at source · line 1282 · raw
@head:Bool -> @c:Cut -> @rest:(@_:Cut -> Reply) -> Reply
a head that has ended, or the reason it has not
def parse.to.go source · line 1292 · raw
@fuel:Nat -> @+head:Bool -> @c:Cut -> Reply
the heads in turn, at most fuel of them
def parse.to source · line 1301 · raw
@+method:String -> @+raw:String -> Reply
the response to a request with this method (RFC 9112 §6.3): interim 1xx heads skipped, and no body for HEAD or a 1xx, 204 or 304 final status
def octs.skip.step source · line 1322 · raw
@short:Bool -> @+n:Nat -> @h:Char -> @t:String -> @rest:(@_:Unit -> Skip) -> Skip
one step of the skip: a character wider than what is left stops it
def octs.skip source · line 1331 · raw
@s:String -> @+n:Nat -> Skip
walk n bytes of UTF-8 off a string, as octs.drop does, saying how it ended
def walk.crlf source · line 1351 · raw
@g:Nat -> @+left:Nat -> @+rest:String -> @ready:Bool -> @go:(@_:String -> Walk) -> Walk
a chunk's data skipped: whether its CRLF has arrived, and on to the next chunk header when it has
def walk.data source · line 1360 · raw
@+g:Nat -> @s:Skip -> @go:(@_:String -> Walk) -> Walk
a chunk's data: all of what arrived, with octets still owed, or its end
def walk.trail source · line 1369 · raw
@g:Nat -> @rest:String -> @ended:Bool -> Walk
the last chunk: ended once its trailer section has
def walk.size source · line 1377 · raw
@+g:Nat -> @rest:String -> @+after:String -> @+n:Nat -> @zero:Bool -> @go:(@_:String -> Walk) -> Walk
a chunk of size n: the last one when n is 0
def walk.hex source · line 1386 · raw
@+g:Nat -> @rest:String -> @+before:String -> @+after:String -> @ok:Bool -> @go:(@_:String -> Walk) -> Walk
a chunk header: a size that is not hex ends the walk (the parse rejects it)
def walk.at source · line 1396 · raw
@+g:Nat -> @rest:String -> @c:Cut -> @go:(@_:String -> Walk) -> Walk
a chunk header that has arrived, or not yet
def walk source · line 1404 · raw
@fuel:Nat -> @+rest:String -> Walk
the walk of chunks.ended from the chunk header at the front of a text
def walk.done source · line 1413 · raw
@w:Walk -> Bool
whether the walk has ended
def walk.more source · line 1425 · raw
@w:Walk -> @+m:Nat -> @b:String -> Walk
the walk once m more characters, b, have arrived
def hear.body source · line 1450 · raw
@f:Frame -> @+after:String -> Hear
a final head's body under its framing
def hear.step source · line 1462 · raw
@asked:Bool -> @+ls:List<&2, String> -> @+after:String -> @interim:Bool -> @go:(@_:String -> Hear) -> Hear
an interim head: on to the next; a final one: its body
def hear.at source · line 1473 · raw
@+g:Nat -> @+asked:Bool -> @raw:String -> @c:Cut -> @go:(@_:String -> Hear) -> Hear
a head that has ended, or not yet
def hear.go source · line 1483 · raw
@fuel:Nat -> @+asked:Bool -> @+raw:String -> Hear
the heads in turn, as whole.go reads them
def hear.of source · line 1493 · raw
@+method:String -> @+raw:String -> Hear
where a response to a request with this method stands, read from the whole text received so far
def hear.done source · line 1497 · raw
@h:Hear -> Bool
whether the response has all arrived
def hear.more source · line 1511 · raw
@h:Hear -> @+b:String -> Hear
where a response stands once more text, b, has arrived
def phrase.chop.at source · line 1528 · raw
@cr:Bool -> @ch:Char -> @tl:String -> @rest:(@_:Unit -> String) -> String
a reason phrase with the CR its line ended with removed; a reason-phrase itself holds no CR (RFC 9112 §4)
def phrase.chop source · line 1543 · raw
@text:String -> String
the text of a reason phrase, a final CR removed
def phrase.code source · line 1551 · raw
@cut:Cut -> String
what follows the status code's SP: the reason phrase; none without that SP
def phrase.after source · line 1559 · raw
@cut:Cut -> String
what follows the version's SP: the status code, an SP and the reason
def phrase.line source · line 1568 · raw
@line:String -> String
a status line's reason phrase (RFC 9112 §4: HTTP-version SP status-code SP [ reason-phrase ]), empty when the line has fewer than two SPs
def phrase.to.step source · line 1572 · raw
@+ls:List<&2, String> -> @+after:String -> @skip:Bool -> @rest:(@_:Cut -> String) -> String
an interim head is skipped, any other gives the reason on its first line
def phrase.to.at source · line 1585 · raw
@cut:Cut -> @rest:(@_:Cut -> String) -> String
a head that has ended, or none
def phrase.to.go source · line 1594 · raw
@fuel:Nat -> @cut:Cut -> String
the heads in turn, at most fuel of them
def phrase.to source · line 1603 · raw
@+raw:String -> String
the reason phrase of the head parse.to stops at: interim 1xx heads with text after them skipped, empty when no head ends