src/echo.bend checks
raw source on the hub · import ezhttp@0.24.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. What is guaranteed is under laws/, such as laws/CookieHeaderEchoesStore.bend.
3 imports
import Base import ./http.bend as Http import ./qs.bend as Qs
Definitions
def wsp source · line 12 · raw
@+c:Char -> Bool
whitespace as RFC 6265 §5.2 strips it: SP or HTAB (RFC 5234 WSP)
def wsp.lead.if source · line 17 · 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 26 · raw
@s:String -> String
a string without its leading WSP
def wsp.trim source · line 34 · raw
@s:String -> String
a string without its leading and trailing WSP
def pair.named source · line 38 · raw
@+name:String -> @value:String -> @empty:Bool -> Maybe<&2, 0x8673751971e75cc0377d73b25bc4d890/src/qs.Kv>
a pair whose name is known: ignored when the name is empty (§5.2 step 5)
def pair.cut source · line 48 · raw
@m:Maybe<&2, 0x8673751971e75cc0377d73b25bc4d890/src/qs.Kv> -> Maybe<&2, 0x8673751971e75cc0377d73b25bc4d890/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 58 · raw
@line:String -> Maybe<&2, 0x8673751971e75cc0377d73b25bc4d890/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 64 · raw
@key:String -> @old:String -> @value:String -> @t:List<&2, 0x8673751971e75cc0377d73b25bc4d890/src/qs.Kv> -> @hit:Bool -> @rest:(@_:Unit -> List<&2, 0x8673751971e75cc0377d73b25bc4d890/src/qs.Kv>) -> List<&2, 0x8673751971e75cc0377d73b25bc4d890/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 75 · raw
@jar:List<&2, 0x8673751971e75cc0377d73b25bc4d890/src/qs.Kv> -> @+name:String -> @+value:String -> List<&2, 0x8673751971e75cc0377d73b25bc4d890/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 85 · raw
@jar:List<&2, 0x8673751971e75cc0377d73b25bc4d890/src/qs.Kv> -> @m:Maybe<&2, 0x8673751971e75cc0377d73b25bc4d890/src/qs.Kv> -> List<&2, 0x8673751971e75cc0377d73b25bc4d890/src/qs.Kv>
a store after one Set-Cookie field value: unchanged when it sets nothing
def store source · line 93 · raw
@lines:List<&2, String> -> @jar:List<&2, 0x8673751971e75cc0377d73b25bc4d890/src/qs.Kv> -> List<&2, 0x8673751971e75cc0377d73b25bc4d890/src/qs.Kv>
a store after Set-Cookie field values, in the order they came
def one source · line 102 · 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 106 · raw
@jar:List<&2, 0x8673751971e75cc0377d73b25bc4d890/src/qs.Kv> -> String
the cookies after the first, each after ; (§5.4 step 4.2)
def line source · line 114 · raw
@jar:List<&2, 0x8673751971e75cc0377d73b25bc4d890/src/qs.Kv> -> String
a store as the Cookie header's value, empty for an empty store
def echo source · line 122 · raw
@lines:List<&2, String> -> String
the Cookie header value to send after these Set-Cookie field values
def values.put source · line 126 · 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 136 · raw
@hs:List<&2, 0x8673751971e75cc0377d73b25bc4d890/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)