src/http.bend checks
raw source on the hub · import ezhttp@0.23.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 254 · raw
Data
the next scan step, or why this chunk header is not usable
StopNext
Go@cut:Cut -> Next
Reject@why:String -> Next
type Size source · line 284 · raw
Data
what a chunk-size line says, before the octets after it are looked at (RFC 9112 §7.1): not a size, the last chunk, or a chunk of n octets
SizeBad@why:String -> Size
SizeLastSize
SizeData@n:Nat -> Size
type Field source · line 518 · raw
Data
the fields a request names: the ones ezhttp writes a default for, the ones it always computes, and every other (laws/RequestHeaderFieldsOrdered.bend)
FHostField
FAgentField
FAcceptField
FConnField
FClenField
FOtherField
type Frame source · line 771 · raw
Data
how a response's body is framed
BareFrame
Sized@n:Nat -> Frame
ChunkedFrame
ClosedFrame
type Plan source · line 850 · raw
Data
what a final head says of its response, before its body is touched: torn, or its status, its fields and how its body is framed
Unplanned@why:String -> Plan
Planned@status:U32 -> @headers:List<&2, Header> -> @frame:Frame -> Plan
type Request source · line 957 · 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 963 · raw
Data
a status code and its reason-phrase
P@code:U32 -> @text:String -> Phrase
type Chunk source · line 1058 · raw
Data
how a chunk of octets is framed: not at all when it is empty, which would end the body, else its size line before it and CRLF after
NoChunkChunk
Chunk@line:String -> Chunk
type Skip source · line 1495 · 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 1521 · 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 1620 · 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 147 · raw
@+_u:U32 -> Nat
octets one received character stands for: one
def octs.len source · line 151 · raw
@s:String -> Nat
how many octets a received text is
def octs.take.step source · line 159 · raw
@short:Bool -> @h:Char -> @rest:(@_:Unit -> String) -> String
one step of the take
def octs.take source · line 167 · 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 176 · raw
@short:Bool -> @h:Char -> @t:String -> @rest:(@_:Unit -> String) -> String
one step of the drop
def octs.drop source · line 185 · raw
@s:String -> @+n:Nat -> String
the rest of a string after this many bytes of UTF-8
def digits.val.of source · line 194 · raw
@+u:U32 -> U32
a decimal digit's value, or 10 when the character is not a digit
def digits.val source · line 198 · raw
@c:Char -> U32
a decimal digit's value, or 10 when the character is not a digit
def digits.step source · line 202 · 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 210 · 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 222 · 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 231 · 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 240 · 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 249 · raw
@+after:String -> @+n:Nat -> Bool
a non-zero chunk has its data and the following CRLF
def chunks.next.of source · line 260 · 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 270 · raw
@+before:String -> @+after:String -> @ok:Bool -> Next
hex check, then the length
def chunks.next source · line 279 · raw
@+before:String -> @+after:String -> Next
classify one chunk header (RFC 9112 §7.1)
def chunk.size.n source · line 290 · raw
@+n:Nat -> @zero:Bool -> Size
a size that is hex: the last chunk when it is 0
def chunk.size.of source · line 298 · raw
@+before:String -> @ok:Bool -> Size
a chunk-size line once it is known whether its size is hex
def chunk.size source · line 307 · raw
@+before:String -> Size
what a chunk-size line says (extensions after ; ignored)
def chunk.short source · line 311 · raw
String
why a chunk whose octets and CRLF have not all arrived is torn
def chunk.next.data source · line 316 · raw
@+after:String -> @+n:Nat -> @ready:Bool -> Next
a chunk of n octets: on to the next chunk header once its octets and CRLF are there
def chunk.next source · line 324 · raw
@z:Size -> @+after:String -> Next
the decoder's step for what a chunk-size line says and the text after it
def chunks.scan.step source · line 334 · raw
@step:Next -> @rest:(@_:Cut -> Maybe<&2, String>) -> Maybe<&2, String>
apply one scan step
def chunks.scan source · line 345 · 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 355 · 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 365 · raw
@fuel:Nat -> @c:Cut -> String
a chunked body put back together (RFC 9112 §7.1)
def dechunk source · line 378 · raw
@+s:String -> String
a Transfer-Encoding: chunked body as the octets it stands for
def head.hit source · line 383 · 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 387 · 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 395 · raw
@ls:List<&2, String> -> @+name:String -> String
the value a head gave a header, "" when it gave none
def head.value source · line 403 · raw
@h:String -> @name:String -> String
this line's trimmed field value
def head.values.cons source · line 407 · 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 416 · 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 425 · raw
@+value:String -> Bool
a field value still holding a line break is obs-fold, which we refuse
def field.keep source · line 429 · 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 437 · 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 442 · raw
@c:Cut -> Maybe<&2, Header>
one header line as a Header, or none when it has no colon
def head.line source · line 450 · raw
@h:String -> Maybe<&2, Header>
one header line as a Header, or none when it has no colon
def head.cons source · line 454 · raw
@m:Maybe<&2, Header> -> @rest:List<&2, Header> -> List<&2, Header>
prepend a parsed header when present
def head.list source · line 462 · raw
@ls:List<&2, String> -> List<&2, Header>
header lines after the status line as a list of fields
def header.line source · line 470 · raw
@h:Header -> String
one request header line
def headers.find.pick source · line 476 · 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 484 · raw
@hs:List<&2, Header> -> @+name:String -> String
case-insensitive field lookup (RFC 9110 §5.1)
def headers.find source · line 493 · raw
@hs:List<&2, Header> -> @+name:String -> String
the value of a field, "" when it is absent
def headers.lines source · line 497 · raw
@hs:List<&2, Header> -> String
extra headers rendered in order
def clen.field source · line 505 · 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 513 · raw
@+n:Nat -> @empty:Bool -> String
Content-Length line when the body is not empty (RFC 9110 §8.6)
def field.rank source · line 527 · raw
@f:Field -> U32
a field's place in the order above
def field.same source · line 543 · raw
@a:Field -> @b:Field -> Bool
whether two fields are the same one
def field.of.clen source · line 547 · raw
@hit:Bool -> Field
a lower-case name that is not content-length
def field.of.conn source · line 555 · raw
@hit:Bool -> @+l:String -> Field
a lower-case name that is not connection
def field.of.accept source · line 563 · raw
@hit:Bool -> @+l:String -> Field
a lower-case name that is not accept
def field.of.agent source · line 571 · raw
@hit:Bool -> @+l:String -> Field
a lower-case name that is not user-agent
def field.of.host source · line 579 · raw
@hit:Bool -> @+l:String -> Field
a lower-case name that is not host
def field.of source · line 587 · raw
@+l:String -> Field
the field a lower-case name names
def field.name source · line 591 · raw
@name:String -> Field
the field a name names, compared case-insensitively (RFC 9110 §5.1)
def header.field source · line 595 · raw
@h:Header -> Field
the field a header line names
def fields.put source · line 601 · 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 610 · raw
@+f:Field -> @hs:List<&2, Header> -> List<&2, Header>
the headers that name one field, in order
def fields.or source · line 618 · 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 632 · 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 644 · 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 650 · 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 659 · 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 667 · 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 676 · 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 680 · 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 686 · 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 693 · 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 698 · raw
@host:String -> @path:String -> @headers:List<&2, Header> -> String
GET with optional headers
def head_req source · line 702 · 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 706 · raw
@host:String -> @path:String -> @headers:List<&2, Header> -> @body:String -> String
POST with body and optional headers
def put_req source · line 711 · 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 716 · 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 721 · 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 725 · raw
@+method:String -> Bool
GET, HEAD, and OPTIONS are safe (RFC 9110 §9.2.1). Tokens are case-sensitive.
def method.idempotent source · line 730 · raw
@+method:String -> Bool
safe methods, plus PUT and DELETE, are idempotent (RFC 9110 §9.2.2)
def token.ok.step source · line 735 · raw
@space:Bool -> @rest:(@_:Unit -> Bool) -> Bool
the rest of a token once this character is known
def token.ok source · line 743 · raw
@s:String -> Bool
a bearer token has no whitespace (RFC 6750 §2.1)
def target.origin source · line 751 · raw
@path:String -> Bool
origin-form request-target: absolute-path, optional query (RFC 9112 §3.2.1)
def target.asterisk source · line 755 · raw
@method:String -> @star:Bool -> Bool
asterisk-form is only * and only for OPTIONS (RFC 9112 §3.2.4)
def target.form source · line 763 · raw
@method:String -> @path:String -> @absolute:Bool -> Bool
origin-form, or OPTIONS asterisk-form
def parse.short source · line 778 · 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 787 · 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 792 · 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 801 · raw
@same:Bool -> @rest:(@_:Unit -> Bool) -> Bool
every Content-Length text equals the first
def clen.agree.go source · line 809 · raw
@rest:List<&2, String> -> @+h:String -> Bool
the tail of a Content-Length list against the first value
def clen.agree source · line 817 · raw
@vs:List<&2, String> -> Bool
duplicate Content-Length fields must be the same digits (RFC 9112 §6.3)
def clen.any source · line 825 · raw
@vs:List<&2, String> -> Bool
whether any Content-Length field was present
def parse.chunked source · line 833 · 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 842 · raw
@status:U32 -> @headers:List<&2, Header> -> @+body:String -> Reply
scan chunk sizes, then decode when they are hex and closed by 0
def plan.clash source · line 855 · raw
@status:U32 -> @headers:List<&2, Header> -> @present:Bool -> Plan
chunked framing, unless a Content-Length is there too (RFC 9112 §6.3 item 3)
def plan.len source · line 863 · raw
@status:U32 -> @headers:List<&2, Header> -> @m:Maybe<&2, Nat> -> Plan
Content-Length when it reads as a number; else the rest of the connection
def plan.te source · line 871 · raw
@status:U32 -> @headers:List<&2, Header> -> @+lens:List<&2, String> -> @chunked:Bool -> Plan
chunked framing, or Content-Length, or the rest of the connection
def plan.agree source · line 880 · raw
@status:U32 -> @headers:List<&2, Header> -> @te:String -> @+lens:List<&2, String> -> @ok:Bool -> Plan
disagreeing Content-Length values are torn before framing
def head.plan source · line 890 · raw
@m:Maybe<&2, U32> -> @+ls:List<&2, String> -> Plan
a final head's plan, its status line read (RFC 9112 §4, §6.3)
def plan.body source · line 900 · raw
@status:U32 -> @headers:List<&2, Header> -> @f:Frame -> @+body:String -> Reply
a body under its framing, as the text parse reads it
def plan.text source · line 913 · raw
@p:Plan -> @+body:String -> Reply
a plan carried out on the text after its head
def parse.status source · line 921 · 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 926 · 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 930 · 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 935 · 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 943 · raw
@raw:String -> Reply
the status, headers, and body of a raw response
def show source · line 947 · raw
@r:Reply -> String
a parsed response on one line, for a test to read
def reasons source · line 967 · raw
List<&2, Phrase>
the reason-phrases RFC 9110 §15 names (RFC 6585 §4 for 429)
def reason.pick source · line 981 · 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 989 · raw
@ps:List<&2, Phrase> -> @+code:U32 -> String
the phrase a list gives a code, "" when it gives none
def reason source · line 997 · raw
@+code:U32 -> String
the reason-phrase for a status code (RFC 9112 §4); "" for one not listed
def respond.head.onto source · line 1002 · raw
@+status:U32 -> @headers:List<&2, Header> -> @+n:Nat -> @rest:String -> String
the head of a reply whose body is n octets, onto what follows it (laws/ReplyHeadFramesBody.bend)
def respond.head source · line 1012 · raw
@+status:U32 -> @headers:List<&2, Header> -> @+n:Nat -> String
the head of a reply whose body is n octets
def respond source · line 1017 · 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 1021 · raw
@+code:U32 -> Bool
204 and 304 are terminated by the header section (RFC 9110 §15.3.5, §15.4.5)
def te.line source · line 1025 · raw
@te:Bool -> String
the Transfer-Encoding line of a streamed reply, when it has a body
def respond.stream source · line 1034 · raw
@+status:U32 -> @headers:List<&2, Header> -> String
the head of a streamed reply: chunked unless the status has no body (RFC 9112 §6.1, §7.1; laws/StreamedRepliesAreChunked.bend)
def hex.nib source · line 1042 · raw
@+v:U32 -> Char
one lowercase hex digit of a value below 16
def hex.at source · line 1047 · raw
@+n:U32 -> @k:Nat -> Char
the 4 bits of n at this shift as a hex digit
def chunk.line source · line 1051 · raw
@+n:U32 -> String
a chunk's size as 8 lowercase hex digits, then CRLF (RFC 9112 §7.1)
def chunk.frame.of source · line 1063 · raw
@+n:U32 -> @empty:Bool -> Chunk
the frame of a chunk once it is known whether it is empty
def chunk.frame source · line 1071 · raw
@+n:U32 -> Chunk
the frame of a chunk of n octets (laws/StreamedRepliesAreChunked.bend)
def chunk.end source · line 1075 · raw
String
the last chunk and the end of a chunked body
def respond.of.body source · line 1079 · 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 1088 · raw
@r:Reply -> String
format a structured Reply as a response message
def reply.for.pick source · line 1096 · 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 1106 · raw
@method:String -> @reply:Reply -> Reply
drop a HEAD response body before it is written
def method.of source · line 1110 · raw
@req:Request -> String
the method token, or "" when the request did not parse
def ask.short source · line 1118 · 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 1127 · 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 1132 · 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 1141 · 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 1150 · 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 1156 · 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 1165 · 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 1174 · 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 1184 · 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 1189 · 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 1200 · 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 1206 · 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 1219 · 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 1227 · raw
@c:Cut -> Request
a request divided into its head and everything after the blank line
def ask source · line 1235 · raw
@raw:String -> Request
the method, target, headers, and body of a raw request
def ask.show source · line 1239 · raw
@r:Request -> String
a parsed request on one line, for a test to read
def status.bare source · line 1250 · 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 1259 · 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 1267 · 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 1275 · 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 1283 · raw
@+lens:List<&2, String> -> @chunked:Bool -> Frame
chunked framing wins over Content-Length (RFC 9112 §6.3 item 4)
def frame source · line 1292 · 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 1300 · raw
@+after:String -> Bool
a zero chunk's trailer section has ended: at once, or after its fields
def chunks.ended.data source · line 1304 · 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 1313 · 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 1322 · 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 1332 · raw
@c:Cut -> @rest:(@_:Cut -> Bool) -> Bool
a chunk header that has arrived, or not yet
def chunks.ended source · line 1340 · raw
@fuel:Nat -> @c:Cut -> Bool
whether a chunked body has reached the end of its last chunk
def whole.of source · line 1348 · raw
@f:Frame -> @+body:String -> Bool
whether a body has all arrived under its framing
def whole.step source · line 1361 · 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 1372 · raw
@asked:Bool -> @c:Cut -> @rest:(@_:Cut -> Bool) -> Bool
a response whose head has ended, or not yet
def whole.go source · line 1381 · raw
@fuel:Nat -> @+asked:Bool -> @c:Cut -> Bool
the heads in turn, at most fuel of them
def whole source · line 1391 · 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 1398 · raw
@+m:Maybe<&2, U32> -> Bool
a 1xx, 204 or 304 response has no body (RFC 9110 §6.4.1)
def head.bare source · line 1402 · raw
@m:Maybe<&2, U32> -> @ls:List<&2, String> -> Plan
a head that has no body: its status and fields (RFC 9110 §6.4.1)
def head.final.of source · line 1410 · raw
@bare:Bool -> @+m:Maybe<&2, U32> -> @+ls:List<&2, String> -> Plan
a final head's plan once it is known whether it has a body
def head.final source · line 1420 · raw
@asked:Bool -> @+ls:List<&2, String> -> Plan
a final head's plan: no body for a reply to HEAD or a 1xx, 204 or 304 status (RFC 9110 §6.4.1, §9.3.2), else as head.plan frames it
def interim.skip.of source · line 1425 · raw
@m:Maybe<&2, U32> -> @more:Bool -> Bool
an interim head is skipped when anything follows it
def interim.skip source · line 1429 · raw
@m:Maybe<&2, U32> -> @after:String -> Bool
an interim head is skipped when more text follows it
def parse.to.bare source · line 1433 · 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 1441 · 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 1450 · 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 1459 · 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 1469 · raw
@fuel:Nat -> @+head:Bool -> @c:Cut -> Reply
the heads in turn, at most fuel of them
def parse.to source · line 1478 · 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 1500 · 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 1509 · 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 1529 · 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 1538 · 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 1547 · raw
@g:Nat -> @rest:String -> @ended:Bool -> Walk
the last chunk: ended once its trailer section has
def walk.size source · line 1555 · 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 1564 · 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 1574 · raw
@+g:Nat -> @rest:String -> @c:Cut -> @go:(@_:String -> Walk) -> Walk
a chunk header that has arrived, or not yet
def walk source · line 1582 · 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 1591 · raw
@w:Walk -> Bool
whether the walk has ended
def walk.more source · line 1603 · raw
@w:Walk -> @+m:Nat -> @b:String -> Walk
the walk once m more characters, b, have arrived
def hear.body source · line 1628 · raw
@f:Frame -> @+after:String -> Hear
a final head's body under its framing
def hear.step source · line 1640 · 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 1651 · 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 1661 · raw
@fuel:Nat -> @+asked:Bool -> @+raw:String -> Hear
the heads in turn, as whole.go reads them
def hear.of source · line 1671 · 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 1675 · raw
@h:Hear -> Bool
whether the response has all arrived
def hear.more source · line 1689 · raw
@h:Hear -> @+b:String -> Hear
where a response stands once more text, b, has arrived
def walk.counts source · line 1704 · raw
@w:Walk -> @+m:Nat -> Bool
whether a walk can be advanced by a count of octets alone: inside a chunk's data that still owes at least that many
def walk.more.n source · line 1717 · raw
@w:Walk -> @+m:Nat -> Walk
a walk advanced by m octets it does not look at (walk.counts says when that is walk.more)
def hear.counts source · line 1732 · raw
@h:Hear -> @+m:Nat -> Bool
whether a state can be advanced by a count of octets alone, without their text: a whole response, a body framed by the close or by Content-Length, or a chunk's data that still owes at least that many (laws/ReadsJudgedByCount.bend)
def hear.more.n source · line 1747 · raw
@h:Hear -> @+m:Nat -> Hear
a state advanced by m octets it does not look at (hear.counts says when that is hear.more)
def phrase.chop.at source · line 1764 · 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 1779 · raw
@text:String -> String
the text of a reason phrase, a final CR removed
def phrase.code source · line 1787 · raw
@cut:Cut -> String
what follows the status code's SP: the reason phrase; none without that SP
def phrase.after source · line 1795 · raw
@cut:Cut -> String
what follows the version's SP: the status code, an SP and the reason
def phrase.line source · line 1804 · 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 1808 · 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 1821 · raw
@cut:Cut -> @rest:(@_:Cut -> String) -> String
a head that has ended, or none
def phrase.to.go source · line 1830 · raw
@fuel:Nat -> @cut:Cut -> String
the heads in turn, at most fuel of them
def phrase.to source · line 1839 · 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