~/bend-docscommunity

src/body.bend checks

raw source on the hub · import emerging-ezhttp@0.21.0.0/src/body.bend as Body

ezhttp/src/body: request entity as empty, UTF-8 text, or packed octets (bend-kit-bytes). Core does not depend on ezjson. Callers plug encode/decode through Bend type parameters (BYO JSON or any other representation).

2 imports
import Base
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes

Types

type Body source · line 9 · raw

Type

what rides in a request: nothing, text, or raw octets

type Shape source · line 16 · raw

Data

what the request text needs to know of a body: its text, or how many octets follow it (SPEC.md HTTP-CLI-10)

Definitions

def body.sized source · line 21 · raw

@r:Pair(0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes, U32) -> Pair(Shape, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes)

an octets body's count: its shape, and the octets handed back

def body.shape source · line 27 · raw

@b:Body -> Pair(Shape, 0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes)

a body as its shape and the octets sent after the request text: a text body's are none, and the empty body is the empty text

def octets.chars source · line 37 · raw

@bs:List<&2, U32> -> String

octets, one character each (each 0..255), from a list of their values

def body.empty source · line 45 · raw

Body

empty body

def body.text source · line 49 · raw

@s:String -> Body

UTF-8 text body

def body.octets source · line 53 · raw

@bytes:0x185ae03c75e3e75be1171471f68b43cb/bytes.Bytes -> Body

octets body

def body.list source · line 58 · raw

@bs:List<&2, U32> -> Body

an octets body from a list of octet values (each 0..255; a value past 255 keeps its low 8 bits)

Templates

template body.encode source · line 62 · raw

@-A:Data -> @-to_text:(@_:A -> String) -> @value:A -> Body

BYO encode: any value to a text body via the caller's encoder

template body.decode source · line 66 · raw

@-A:Data -> @-from_text:(@_:String -> Maybe<&2, A>) -> @s:String -> Maybe<&2, A>

BYO decode: body text to a value via the caller's decoder