~/bend-docscommunity

src/echo.bend checks

raw source on the hub · import emerging-ezhttp@0.19.0.0/src/echo.bend as Echo

ezhttp/src/echo: the Cookie request header a client sends back after Set-Cookie fields, reduced to names and values (RFC 6265 §5.2 parsing, §5.3 step 11 replacement, §5.4 serialization). No attribute is read: no Domain, Path, Expires, Max-Age, Secure or HttpOnly, so nothing expires and every cookie goes back. Pure. SPEC.md HTTP-CK lists what is guaranteed.

3 imports
import Base
import ./http.bend as Http
import ./qs.bend as Qs

Definitions

def wsp source · line 11 · raw

@+c:Char -> Bool

whitespace as RFC 6265 §5.2 strips it: SP or HTAB (RFC 5234 WSP)

def wsp.lead.if source · line 16 · raw

@t:String -> @+h:Char -> @space:Bool -> @rest:(@_:Unit -> String) -> String

one character of the leading strip: dropped, and the strip goes on, when it is WSP

def wsp.lead source · line 25 · raw

@s:String -> String

a string without its leading WSP

def wsp.trim source · line 33 · raw

@s:String -> String

a string without its leading and trailing WSP

def pair.named source · line 37 · raw

@+name:String -> @value:String -> @empty:Bool -> Maybe<&2, 0x60f672946f1b37cf58e2c05154bec295/src/qs.Kv>

a pair whose name is known: ignored when the name is empty (§5.2 step 5)

def pair.cut source · line 47 · raw

@m:Maybe<&2, 0x60f672946f1b37cf58e2c05154bec295/src/qs.Kv> -> Maybe<&2, 0x60f672946f1b37cf58e2c05154bec295/src/qs.Kv>

the name-value-pair cut at its first =: none without one (§5.2 step 2), else the name before it and the value after it, each without leading and trailing WSP (steps 3, 4)

def pair source · line 57 · raw

@line:String -> Maybe<&2, 0x60f672946f1b37cf58e2c05154bec295/src/qs.Kv>

the cookie one Set-Cookie field value sets: its name-value-pair is the text before its first ;, all of it without one (§5.2 step 1)

def put.at source · line 63 · raw

@key:String -> @old:String -> @value:String -> @t:List<&2, 0x60f672946f1b37cf58e2c05154bec295/src/qs.Kv> -> @hit:Bool -> @rest:(@_:Unit -> List<&2, 0x60f672946f1b37cf58e2c05154bec295/src/qs.Kv>) -> List<&2, 0x60f672946f1b37cf58e2c05154bec295/src/qs.Kv>

one stored cookie, once it is known whether it has the new one's name: that one takes the new value in its place, any other is kept and the rest of the store looked at

def put source · line 74 · raw

@jar:List<&2, 0x60f672946f1b37cf58e2c05154bec295/src/qs.Kv> -> @+name:String -> @+value:String -> List<&2, 0x60f672946f1b37cf58e2c05154bec295/src/qs.Kv>

a cookie put in a store: a stored one of the same name (compared exactly) keeps its place and takes the new value (§5.3 step 11.3 keeps its creation-time, which orders it, §5.4 step 2), else it goes after the others

def add source · line 84 · raw

@jar:List<&2, 0x60f672946f1b37cf58e2c05154bec295/src/qs.Kv> -> @m:Maybe<&2, 0x60f672946f1b37cf58e2c05154bec295/src/qs.Kv> -> List<&2, 0x60f672946f1b37cf58e2c05154bec295/src/qs.Kv>

a store after one Set-Cookie field value: unchanged when it sets nothing

def store source · line 92 · raw

@lines:List<&2, String> -> @jar:List<&2, 0x60f672946f1b37cf58e2c05154bec295/src/qs.Kv> -> List<&2, 0x60f672946f1b37cf58e2c05154bec295/src/qs.Kv>

a store after Set-Cookie field values, in the order they came

def one source · line 101 · raw

@name:String -> @value:String -> String

one cookie in the Cookie header: its name, =, its value (§5.4 step 4.1)

def more source · line 105 · raw

@jar:List<&2, 0x60f672946f1b37cf58e2c05154bec295/src/qs.Kv> -> String

the cookies after the first, each after ; (§5.4 step 4.2)

def line source · line 113 · raw

@jar:List<&2, 0x60f672946f1b37cf58e2c05154bec295/src/qs.Kv> -> String

a store as the Cookie header's value, empty for an empty store

def echo source · line 121 · raw

@lines:List<&2, String> -> String

the Cookie header value to send after these Set-Cookie field values

def values.put source · line 125 · raw

@value:String -> @rest:List<&2, String> -> @hit:Bool -> List<&2, String>

one header field: its value in front of the rest when it is Set-Cookie

def values source · line 135 · raw

@hs:List<&2, 0x60f672946f1b37cf58e2c05154bec295/src/http.Header> -> List<&2, String>

the values of the Set-Cookie fields among response headers, in order (field names compared case-insensitively, RFC 9110 §5.1)