src/http.bend checks
raw source on the hub · import bend-kube-runtime@0.5.4.0/src/http.bend as Http
2 imports
import Base import ./utf8.bend as U
Types
type Header source · line 12 · raw
Data
Header@name:String -> @value:String -> Header
type Req source · line 15 · raw
Data
Req@method:String -> @path:String -> @headers:List<&2, Header> -> @body:String -> Req
type Head source · line 18 · raw
Data
Head@status:U32 -> @reason:String -> @headers:List<&2, Header> -> Head
type Phase source · line 30 · raw
Data
Where the decoder is. PHead: header bytes, reversed, and how much of CRLF CRLF ends them PLen: body bytes left under Content-Length PSize: a chunk's hex size so far; ext once past a ';' extension PData: chunk bytes left; PCrlf: the CRLF after a chunk's data PTrail: trailer lines after the last chunk; blank if this line is empty PClose: a body that runs to the end of the stream PErr: a broken response; PLost: the connection failed before any byte of a response (a request on it may safely be retried)
PHead@buf:List<&2, U32> -> @tail:U32 -> Phase
PLen@left:U32 -> Phase
PSize@size:U32 -> @ext:Bool -> @any:Bool -> Phase
PData@left:U32 -> Phase
PCrlfPhase
PTrail@blank:Bool -> Phase
PClosePhase
PDonePhase
PErr@msg:String -> Phase
PLost@msg:String -> Phase
type Resp source · line 44 · raw
Data
The decoder: its phase, the head once read, and body bytes decoded since the last take, reversed.
Resp@phase:Phase -> @head:Maybe<&2, Head> -> @out:List<&2, U32> -> Resp
Definitions
def Http.lower source · line 50 · raw
@s:String -> String
def Http.header.if source · line 53 · raw
@+name:String -> @v:String -> @t:List<&2, Header> -> @hit:Bool -> Maybe<&2, String>
def Http.header source · line 61 · raw
@+name:String -> @hs:List<&2, Header> -> Maybe<&2, String>
def Http.find source · line 69 · raw
@hs:List<&2, Header> -> @+name:String -> Maybe<&2, String>
The first header named name (case-insensitive).
def Http.render_headers source · line 79 · raw
@hs:List<&2, Header> -> String
def Http.render source · line 88 · raw
@req:Req -> @host:String -> String
The request's bytes, as text: a Host header, the given headers, and a Content-Length that counts the body's UTF-8 bytes.
def Http.pct_hex.if source · line 95 · raw
@+n:U32 -> @lt:Bool -> Char
def Http.pct_hex source · line 103 · raw
@+n:U32 -> Char
Percent-encodes a query or path component (RFC 3986 unreserved kept).
def Http.keep source · line 106 · raw
@c:Char -> Bool
def Http.pct_bytes source · line 119 · raw
@bs:List<&2, U32> -> @rest:String -> String
def Http.encode.chr source · line 127 · raw
@+c:Char -> @rest:String -> @keep:Bool -> String
def Http.encode source · line 134 · raw
@s:String -> String
def Http.parse_header.go source · line 141 · raw
@parts:List<&2, String> -> Maybe<&2, Header>
def Http.parse_header source · line 151 · raw
@line:String -> Maybe<&2, Header>
def Http.parse_headers.put source · line 154 · raw
@h:Maybe<&2, Header> -> @rest:List<&2, Header> -> List<&2, Header>
def Http.parse_headers source · line 161 · raw
@lines:List<&2, String> -> List<&2, Header>
def Http.parse_status.fin source · line 168 · raw
@code:Maybe<&2, U32> -> @reason:String -> Maybe<&1, Pair(U32, String)>
def Http.parse_status.go source · line 175 · raw
@parts:List<&2, String> -> Maybe<&1, Pair(U32, String)>
def Http.parse_status source · line 183 · raw
@line:String -> Maybe<&1, Pair(U32, String)>
"HTTP/1.1 200 OK": the status and the reason.
def Http.parse_head.fin source · line 186 · raw
@st:Maybe<&1, Pair(U32, String)> -> @hs:List<&2, Header> -> Maybe<&2, Head>
def Http.parse_head.go source · line 193 · raw
@lines:List<&2, String> -> Maybe<&2, Head>
def Http.parse_head source · line 200 · raw
@text:String -> Maybe<&2, Head>
def Http.framing.te source · line 203 · raw
@chunked:Bool -> Phase
def Http.framing.len.if source · line 210 · raw
@+k:U32 -> @zero:Bool -> Phase
def Http.framing.len source · line 217 · raw
@n:Maybe<&2, U32> -> Phase
def Http.framing.pick source · line 224 · raw
@none:Bool -> @te:Maybe<&2, String> -> @cl:Maybe<&2, String> -> Phase
def Http.no_body source · line 235 · raw
@+code:U32 -> Bool
def Http.framing.go source · line 238 · raw
@+code:U32 -> @te:Maybe<&2, String> -> @cl:Maybe<&2, String> -> Phase
def Http.framing source · line 243 · raw
@+h:Head -> Phase
The body's framing, once the head is read: chunked, a length, or none (204, 304 and 1xx carry no body).
def Http.resp.init source · line 251 · raw
Resp
def Http.head_tail.go source · line 254 · raw
@+tail:U32 -> @cr:Bool -> @lf:Bool -> @even:Bool -> U32
def Http.head_tail source · line 266 · raw
@+tail:U32 -> @+b:U32 -> U32
How far into CRLF CRLF the head is after byte b.
def Http.end_head.go source · line 269 · raw
@h:Maybe<&2, Head> -> Resp
def Http.end_head source · line 276 · raw
@buf:List<&2, U32> -> Resp
def Http.step.head.end source · line 279 · raw
@buf:List<&2, U32> -> @+tail:U32 -> @done:Bool -> Resp
def Http.step.head.if source · line 286 · raw
@buf:List<&2, U32> -> @+tail:U32 -> Resp
def Http.step.head source · line 289 · raw
@buf:List<&2, U32> -> @+tail:U32 -> @+b:U32 -> Resp
def Http.count.if source · line 292 · raw
@+left:U32 -> @chunk:Bool -> @zero:Bool -> Phase
def Http.count source · line 304 · raw
@+left:U32 -> @chunk:Bool -> Phase
A counted run of body bytes: PLen or PData, with what follows at zero.
def Http.hex.pick source · line 307 · raw
@+c:U32 -> @digit:Bool -> @lower:Bool -> @upper:Bool -> Maybe<&2, U32>
def Http.hex.go source · line 318 · raw
@+c:U32 -> @a:Bool -> @b:Bool -> @d:Bool -> @e:Bool -> @f:Bool -> @g:Bool -> Maybe<&2, U32>
def Http.hex source · line 321 · raw
@+c:U32 -> Maybe<&2, U32>
def Http.step.size.digit source · line 325 · raw
@+size:U32 -> @+v:U32 -> @big:Bool -> Phase
def Http.step.size.end source · line 332 · raw
@+size:U32 -> @last:Bool -> Phase
def Http.step.size.go source · line 339 · raw
@+size:U32 -> @lf:Bool -> @ext:Bool -> @h:Maybe<&2, U32> -> @semi:Bool -> @cr:Bool -> @any:Bool -> Phase
def Http.step.size source · line 359 · raw
@+size:U32 -> @ext:Bool -> @any:Bool -> @+b:U32 -> Phase
A byte of a chunk-size line. The line ends at LF; a zero size means the last chunk, and its trailers follow.
def Http.step.crlf.go source · line 363 · raw
@cr:Bool -> @lf:Bool -> Phase
def Http.step.crlf source · line 372 · raw
@+b:U32 -> Phase
def Http.step.trail.go source · line 375 · raw
@lf:Bool -> @cr:Bool -> @blank:Bool -> Phase
def Http.step.trail source · line 386 · raw
@blank:Bool -> @+b:U32 -> Phase
def Http.step source · line 390 · raw
@r:Resp -> @+b:U32 -> Resp
One byte.
def Http.feed source · line 414 · raw
@bs:List<&2, U32> -> @r:Resp -> Resp
Feeds a cut of bytes.
def Http.take source · line 422 · raw
@r:Resp -> Pair(Resp, List<&2, U32>)
Takes the body bytes decoded so far, in order, leaving none behind.
def Http.eof source · line 428 · raw
@r:Resp -> Resp
The stream ended: a read-until-close body is then complete.
def Http.is_done source · line 443 · raw
@r:Resp -> Bool
def Http.error source · line 450 · raw
@r:Resp -> Maybe<&2, String>
def Http.decode.fin source · line 459 · raw
@rb:Pair(Resp, List<&2, U32>) -> Result<&2, &1, String, Pair(Head, String)>
def Http.decode source · line 471 · raw
@bs:List<&2, U32> -> Result<&2, &1, String, Pair(Head, String)>
A whole response from its bytes: the head and the decoded body.
def Lines.cur.if source · line 474 · raw
@+b:U32 -> @cur:List<&2, U32> -> @lf:Bool -> List<&2, U32>
def Lines.cur source · line 481 · raw
@+b:U32 -> @+cur:List<&2, U32> -> List<&2, U32>
def Lines.done.if source · line 484 · raw
@cur:List<&2, U32> -> @done:List<&2, List<&2, U32>> -> @lf:Bool -> List<&2, List<&2, U32>>
def Lines.done source · line 492 · raw
@+b:U32 -> @+cur:List<&2, U32> -> @done:List<&2, List<&2, U32>> -> List<&2, List<&2, U32>>
def Lines.go source · line 502 · raw
@bs:List<&2, U32> -> @+cur:List<&2, U32> -> @done:List<&2, List<&2, U32>> -> Pair(List<&2, U32>, List<&2, List<&2, U32>>)
def Lines.split.fin source · line 510 · raw
@r:Pair(List<&2, U32>, List<&2, List<&2, U32>>) -> Pair(List<&2, U32>, List<&2, List<&2, U32>>)
def Lines.split source · line 517 · raw
@cur:List<&2, U32> -> @bs:List<&2, U32> -> Pair(List<&2, U32>, List<&2, List<&2, U32>>)
Splits a cut: the carried partial line, and the whole lines, in order.