src/packed.bend checks
raw source on the hub · import emerging-ezhttp@0.21.0.0/src/packed.bend as Packed
ezhttp/src/packed: a response read off its packed octets (bend-kit-bytes), so its body is never turned into text. Only the heads and the chunk-size lines are read as text, a few octets each; every decision is src/http.bend's, the same one its text parse makes (SPEC.md HTTP-CLI-15): which head is final and what its plan is (head.final), its reason phrase (phrase.line), and what each chunk-size line says (chunk.size). This module only finds those lines and copies the body's octets out (SPEC.md HTTP-TRUST-9).
3 imports
import Base import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes import ./http.bend as Http
Types
type Got source · line 15 · raw
Type
a response read off its octets: torn, or its status, its header fields and reason phrase as octet text, and its body's octets
Torn@why:String -> Got
Got@status:U32 -> @headers:List<&2, 0xedb2120a04a47dc18c3a756ec7c62750/src/http.Header> -> @reason:String -> @body:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Got
type Parts source · line 21 · raw
Type
a chunked body's octets so far, newest first, or why it was torn
Bad@why:String -> Parts
Parts@parts:List<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> Parts
Definitions
def packed.text.of source · line 26 · raw
@r:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes) -> Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, String)
a slice's copy as text, the buffer kept
def packed.text source · line 31 · raw
@b:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+at:U32 -> @+n:U32 -> Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, String)
n octets from at as text (a head or a chunk-size line), the buffer kept
def packed.copy source · line 35 · raw
@b:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+at:U32 -> @+n:U32 -> 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes
n octets from at, the buffer dropped
def packed.chunk.take source · line 41 · raw
@r:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes) -> @+next:U32 -> @acc:List<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @go:(@_:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @_:U32 -> @_:List<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> Parts) -> Parts
a chunk's octets copied out, then on to the chunk-size line after its CRLF
def packed.chunk.ready.is source · line 48 · raw
@b:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+d:U32 -> @+k:U32 -> @acc:List<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @ready:Bool -> @go:(@_:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @_:U32 -> @_:List<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> Parts) -> Parts
a chunk of k octets from d, ready when its CRLF follows them
def packed.chunk.ready source · line 58 · raw
@r:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, String) -> @+d:U32 -> @+k:U32 -> @acc:List<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @go:(@_:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @_:U32 -> @_:List<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> Parts) -> Parts
a chunk of k octets from d whose CRLF has been looked for (chunks.ready)
def packed.chunk.data source · line 66 · raw
@b:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+d:U32 -> @+n:Nat -> @acc:List<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @fits:Bool -> @go:(@_:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @_:U32 -> @_:List<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> Parts) -> Parts
a chunk of n octets from d: its octets must all be there, and a CRLF after them
def packed.chunk.size source · line 77 · raw
@b:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+d:U32 -> @+len:U32 -> @acc:List<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @z:0xedb2120a04a47dc18c3a756ec7c62750/src/http.Size -> @go:(@_:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @_:U32 -> @_:List<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> Parts) -> Parts
what a chunk-size line says, acted on with the octets after it
def packed.chunk.line source · line 90 · raw
@r:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, String) -> @+d:U32 -> @+len:U32 -> @acc:List<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @go:(@_:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @_:U32 -> @_:List<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> Parts) -> Parts
a chunk-size line read, its octets after its CRLF
def packed.chunk.at source · line 97 · raw
@r:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, Maybe<&2, U32>) -> @+p:U32 -> @+len:U32 -> @acc:List<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> @go:(@_:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @_:U32 -> @_:List<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> Parts) -> Parts
a chunk-size line that ends at i, or none ends: the body ends there
def packed.chunks source · line 109 · raw
@fuel:Nat -> @b:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+p:U32 -> @+len:U32 -> @acc:List<&1, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes> -> Parts
the chunks from the chunk-size line at p, at most fuel of them
def packed.chunked source · line 119 · raw
@st:U32 -> @hs:List<&2, 0xedb2120a04a47dc18c3a756ec7c62750/src/http.Header> -> @reason:String -> @r:Parts -> Got
a chunked body's octets in order, or why it was torn
def packed.sized source · line 130 · raw
@st:U32 -> @hs:List<&2, 0xedb2120a04a47dc18c3a756ec7c62750/src/http.Header> -> @reason:String -> @b:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+q:U32 -> @+n:Nat -> @short:Bool -> Got
a body framed by Content-Length: torn when fewer octets arrived
def packed.body source · line 139 · raw
@st:U32 -> @hs:List<&2, 0xedb2120a04a47dc18c3a756ec7c62750/src/http.Header> -> @reason:String -> @f:0xedb2120a04a47dc18c3a756ec7c62750/src/http.Frame -> @b:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+q:U32 -> @+len:U32 -> Got
the octets after the final head, as its framing says
def packed.final source · line 154 · raw
@p:0xedb2120a04a47dc18c3a756ec7c62750/src/http.Plan -> @reason:String -> @b:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+q:U32 -> @+len:U32 -> Got
the final head's plan carried out on the octets after it
def packed.step source · line 165 · raw
@+asked:Bool -> @b:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+q:U32 -> @+len:U32 -> @+ls:List<&2, String> -> @skip:Bool -> @rest:(@_:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @_:U32 -> Got) -> Got
an interim head is skipped, any other is the final one
def packed.head.text source · line 175 · raw
@+asked:Bool -> @r:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, String) -> @+q:U32 -> @+len:U32 -> @rest:(@_:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @_:U32 -> Got) -> Got
a head read as text, and the octets after its blank line from q
def packed.head source · line 183 · raw
@+asked:Bool -> @r:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, Maybe<&2, U32>) -> @+p:U32 -> @+len:U32 -> @rest:(@_:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @_:U32 -> Got) -> Got
a head that ends at i, or none ends
def packed.heads source · line 194 · raw
@fuel:Nat -> @+asked:Bool -> @b:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> @+p:U32 -> @+len:U32 -> Got
the heads in turn from p, at most fuel of them
def packed.reply.of source · line 204 · raw
@+method:String -> @r:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, U32) -> Got
the response to a request with this method, its octets counted
def packed.reply source · line 210 · raw
@+method:String -> @b:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Got
the response to a request with this method, read off its octets as parse.to reads its text (SPEC.md HTTP-CLI-9, HTTP-CLI-15, HTTP-TRUST-9)