~/bend-docscommunity

src/http.bend checks

raw source on the hub · import emerging-ezhttp@0.21.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

type Reply source · line 17 · raw

Data

what a response turned out to be: status, headers, framed body — or why not

type Next source · line 253 · raw

Data

the next scan step, or why this chunk header is not usable

type Size source · line 283 · 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

type Field source · line 517 · 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)

type Frame source · line 770 · raw

Data

how a response's body is framed

type Plan source · line 849 · 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

type Request source · line 956 · raw

Data

a request that came apart, or the reason it would not (RFC 9112 §3)

type Phrase source · line 962 · raw

Data

a status code and its reason-phrase

type Chunk source · line 1057 · 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

type Skip source · line 1493 · 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

type Walk source · line 1519 · 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.

type Hear source · line 1618 · 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

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 chunk.size.n source · line 289 · raw

@+n:Nat -> @zero:Bool -> Size

a size that is hex: the last chunk when it is 0

def chunk.size.of source · line 297 · raw

@+before:String -> @ok:Bool -> Size

a chunk-size line once it is known whether its size is hex

def chunk.size source · line 306 · raw

@+before:String -> Size

what a chunk-size line says (extensions after ; ignored)

def chunk.short source · line 310 · raw

String

why a chunk whose octets and CRLF have not all arrived is torn

def chunk.next.data source · line 315 · 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 323 · 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 333 · raw

@step:Next -> @rest:(@_:Cut -> Maybe<&2, String>) -> Maybe<&2, String>

apply one scan step

def chunks.scan source · line 344 · 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 354 · 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 364 · raw

@fuel:Nat -> @c:Cut -> String

a chunked body put back together (RFC 9112 §7.1)

def dechunk source · line 377 · raw

@+s:String -> String

a Transfer-Encoding: chunked body as the octets it stands for

def head.hit source · line 382 · 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 386 · 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 394 · raw

@ls:List<&2, String> -> @+name:String -> String

the value a head gave a header, "" when it gave none

def head.value source · line 402 · raw

@h:String -> @name:String -> String

this line's trimmed field value

def head.values.cons source · line 406 · 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 415 · 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 424 · raw

@+value:String -> Bool

a field value still holding a line break is obs-fold, which we refuse

def field.keep source · line 428 · 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 436 · 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 441 · raw

@c:Cut -> Maybe<&2, Header>

one header line as a Header, or none when it has no colon

def head.line source · line 449 · raw

@h:String -> Maybe<&2, Header>

one header line as a Header, or none when it has no colon

def head.cons source · line 453 · raw

@m:Maybe<&2, Header> -> @rest:List<&2, Header> -> List<&2, Header>

prepend a parsed header when present

def head.list source · line 461 · raw

@ls:List<&2, String> -> List<&2, Header>

header lines after the status line as a list of fields

def header.line source · line 469 · raw

@h:Header -> String

one request header line

def headers.find.pick source · line 475 · 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 483 · raw

@hs:List<&2, Header> -> @+name:String -> String

case-insensitive field lookup (RFC 9110 §5.1)

def headers.find source · line 492 · raw

@hs:List<&2, Header> -> @+name:String -> String

the value of a field, "" when it is absent

def headers.lines source · line 496 · raw

@hs:List<&2, Header> -> String

extra headers rendered in order

def clen.field source · line 504 · 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 512 · raw

@+n:Nat -> @empty:Bool -> String

Content-Length line when the body is not empty (RFC 9110 §8.6)

def field.rank source · line 526 · raw

@f:Field -> U32

a field's place in the order above

def field.same source · line 542 · raw

@a:Field -> @b:Field -> Bool

whether two fields are the same one

def field.of.clen source · line 546 · raw

@hit:Bool -> Field

a lower-case name that is not content-length

def field.of.conn source · line 554 · raw

@hit:Bool -> @+l:String -> Field

a lower-case name that is not connection

def field.of.accept source · line 562 · raw

@hit:Bool -> @+l:String -> Field

a lower-case name that is not accept

def field.of.agent source · line 570 · raw

@hit:Bool -> @+l:String -> Field

a lower-case name that is not user-agent

def field.of.host source · line 578 · raw

@hit:Bool -> @+l:String -> Field

a lower-case name that is not host

def field.of source · line 586 · raw

@+l:String -> Field

the field a lower-case name names

def field.name source · line 590 · raw

@name:String -> Field

the field a name names, compared case-insensitively (RFC 9110 §5.1)

def header.field source · line 594 · raw

@h:Header -> Field

the field a header line names

def fields.put source · line 600 · 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 609 · raw

@+f:Field -> @hs:List<&2, Header> -> List<&2, Header>

the headers that name one field, in order

def fields.or source · line 617 · 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 631 · 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 643 · 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 649 · 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 658 · 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 666 · 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 675 · 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 679 · 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 685 · 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 692 · 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 697 · raw

@host:String -> @path:String -> @headers:List<&2, Header> -> String

GET with optional headers

def head_req source · line 701 · 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 705 · raw

@host:String -> @path:String -> @headers:List<&2, Header> -> @body:String -> String

POST with body and optional headers

def put_req source · line 710 · 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 715 · 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 720 · 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 724 · raw

@+method:String -> Bool

GET, HEAD, and OPTIONS are safe (RFC 9110 §9.2.1). Tokens are case-sensitive.

def method.idempotent source · line 729 · raw

@+method:String -> Bool

safe methods, plus PUT and DELETE, are idempotent (RFC 9110 §9.2.2)

def token.ok.step source · line 734 · raw

@space:Bool -> @rest:(@_:Unit -> Bool) -> Bool

the rest of a token once this character is known

def token.ok source · line 742 · raw

@s:String -> Bool

a bearer token has no whitespace (RFC 6750 §2.1)

def target.origin source · line 750 · raw

@path:String -> Bool

origin-form request-target: absolute-path, optional query (RFC 9112 §3.2.1)

def target.asterisk source · line 754 · raw

@method:String -> @star:Bool -> Bool

asterisk-form is only * and only for OPTIONS (RFC 9112 §3.2.4)

def target.form source · line 762 · raw

@method:String -> @path:String -> @absolute:Bool -> Bool

origin-form, or OPTIONS asterisk-form

def parse.short source · line 777 · 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 786 · 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 791 · 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 800 · raw

@same:Bool -> @rest:(@_:Unit -> Bool) -> Bool

every Content-Length text equals the first

def clen.agree.go source · line 808 · raw

@rest:List<&2, String> -> @+h:String -> Bool

the tail of a Content-Length list against the first value

def clen.agree source · line 816 · raw

@vs:List<&2, String> -> Bool

duplicate Content-Length fields must be the same digits (RFC 9112 §6.3)

def clen.any source · line 824 · raw

@vs:List<&2, String> -> Bool

whether any Content-Length field was present

def parse.chunked source · line 832 · 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 841 · 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 854 · 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 862 · 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 870 · 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 879 · 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 889 · 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 899 · 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 912 · raw

@p:Plan -> @+body:String -> Reply

a plan carried out on the text after its head

def parse.status source · line 920 · 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 925 · 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 929 · 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 934 · 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 942 · raw

@raw:String -> Reply

the status, headers, and body of a raw response

def show source · line 946 · raw

@r:Reply -> String

a parsed response on one line, for a test to read

def reasons source · line 966 · raw

List<&2, Phrase>

the reason-phrases RFC 9110 §15 names (RFC 6585 §4 for 429)

def reason.pick source · line 980 · 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 988 · raw

@ps:List<&2, Phrase> -> @+code:U32 -> String

the phrase a list gives a code, "" when it gives none

def reason source · line 996 · raw

@+code:U32 -> String

the reason-phrase for a status code (RFC 9112 §4); "" for one not listed

def respond.head.onto source · line 1001 · 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 (SPEC.md HTTP-SRV-6)

def respond.head source · line 1011 · raw

@+status:U32 -> @headers:List<&2, Header> -> @+n:Nat -> String

the head of a reply whose body is n octets

def respond source · line 1016 · 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 1020 · 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 1024 · raw

@te:Bool -> String

the Transfer-Encoding line of a streamed reply, when it has a body

def respond.stream source · line 1033 · 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; SPEC.md HTTP-SRV-7)

def hex.nib source · line 1041 · raw

@+v:U32 -> Char

one lowercase hex digit of a value below 16

def hex.at source · line 1046 · raw

@+n:U32 -> @k:Nat -> Char

the 4 bits of n at this shift as a hex digit

def chunk.line source · line 1050 · 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 1062 · raw

@+n:U32 -> @empty:Bool -> Chunk

the frame of a chunk once it is known whether it is empty

def chunk.frame source · line 1070 · raw

@+n:U32 -> Chunk

the frame of a chunk of n octets (SPEC.md HTTP-SRV-7)

def chunk.end source · line 1074 · raw

String

the last chunk and the end of a chunked body

def respond.of.body source · line 1078 · 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 1087 · raw

@r:Reply -> String

format a structured Reply as a response message

def reply.for.pick source · line 1095 · 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 1105 · raw

@method:String -> @reply:Reply -> Reply

drop a HEAD response body before it is written

def method.of source · line 1109 · raw

@req:Request -> String

the method token, or "" when the request did not parse

def ask.short source · line 1117 · 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 1126 · 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 1131 · 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 1140 · 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 1149 · 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 1155 · 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 1164 · 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 1173 · 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 1183 · 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 1188 · 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 1199 · 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 1205 · 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 1218 · 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 1226 · raw

@c:Cut -> Request

a request divided into its head and everything after the blank line

def ask source · line 1234 · raw

@raw:String -> Request

the method, target, headers, and body of a raw request

def ask.show source · line 1238 · raw

@r:Request -> String

a parsed request on one line, for a test to read

def status.bare source · line 1249 · 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 1258 · 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 1266 · 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 1274 · 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 1282 · raw

@+lens:List<&2, String> -> @chunked:Bool -> Frame

chunked framing wins over Content-Length (RFC 9112 §6.3 item 4)

def frame source · line 1291 · 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 1299 · raw

@+after:String -> Bool

a zero chunk's trailer section has ended: at once, or after its fields

def chunks.ended.data source · line 1303 · 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 1312 · 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 1321 · 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 1331 · raw

@c:Cut -> @rest:(@_:Cut -> Bool) -> Bool

a chunk header that has arrived, or not yet

def chunks.ended source · line 1339 · raw

@fuel:Nat -> @c:Cut -> Bool

whether a chunked body has reached the end of its last chunk

def whole.of source · line 1347 · raw

@f:Frame -> @+body:String -> Bool

whether a body has all arrived under its framing

def whole.step source · line 1360 · 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 1371 · raw

@asked:Bool -> @c:Cut -> @rest:(@_:Cut -> Bool) -> Bool

a response whose head has ended, or not yet

def whole.go source · line 1380 · raw

@fuel:Nat -> @+asked:Bool -> @c:Cut -> Bool

the heads in turn, at most fuel of them

def whole source · line 1390 · 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 1397 · 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 1401 · 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 1409 · 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 1419 · 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 1424 · raw

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

an interim head is skipped when anything follows it

def interim.skip source · line 1428 · raw

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

an interim head is skipped when more text follows it

def parse.to.bare source · line 1432 · 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 1440 · 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 1449 · 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 1458 · 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 1468 · raw

@fuel:Nat -> @+head:Bool -> @c:Cut -> Reply

the heads in turn, at most fuel of them

def parse.to source · line 1477 · 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 1498 · 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 1507 · 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 1527 · 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 1536 · 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 1545 · raw

@g:Nat -> @rest:String -> @ended:Bool -> Walk

the last chunk: ended once its trailer section has

def walk.size source · line 1553 · 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 1562 · 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 1572 · raw

@+g:Nat -> @rest:String -> @c:Cut -> @go:(@_:String -> Walk) -> Walk

a chunk header that has arrived, or not yet

def walk source · line 1580 · 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 1589 · raw

@w:Walk -> Bool

whether the walk has ended

def walk.more source · line 1601 · raw

@w:Walk -> @+m:Nat -> @b:String -> Walk

the walk once m more characters, b, have arrived

def hear.body source · line 1626 · raw

@f:Frame -> @+after:String -> Hear

a final head's body under its framing

def hear.step source · line 1638 · 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 1649 · 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 1659 · raw

@fuel:Nat -> @+asked:Bool -> @+raw:String -> Hear

the heads in turn, as whole.go reads them

def hear.of source · line 1669 · 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 1673 · raw

@h:Hear -> Bool

whether the response has all arrived

def hear.more source · line 1687 · raw

@h:Hear -> @+b:String -> Hear

where a response stands once more text, b, has arrived

def walk.counts source · line 1702 · 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 1715 · 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 1729 · 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 (SPEC.md HTTP-CLI-6)

def hear.more.n source · line 1744 · 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 1761 · 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 1776 · raw

@text:String -> String

the text of a reason phrase, a final CR removed

def phrase.code source · line 1784 · raw

@cut:Cut -> String

what follows the status code's SP: the reason phrase; none without that SP

def phrase.after source · line 1792 · raw

@cut:Cut -> String

what follows the version's SP: the status code, an SP and the reason

def phrase.line source · line 1801 · 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 1805 · 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 1818 · raw

@cut:Cut -> @rest:(@_:Cut -> String) -> String

a head that has ended, or none

def phrase.to.go source · line 1827 · raw

@fuel:Nat -> @cut:Cut -> String

the heads in turn, at most fuel of them

def phrase.to source · line 1836 · 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