def Http.render

bend-kube-runtime@0.2.0.0 · src/http.bend:86

import bend-kube-runtime@0.2.0.0/src/http.bend as Http
import Base
import bend-kube-runtime@0.2.0.0/src/utf8.bend as U

86# The request's bytes, as text: a Host header, the given headers, and a
87# Content-Length that counts the body's UTF-8 bytes.
88def Http.render(req: Req, host: String) -> String:
89  match req:
90    case Req{m, p, hs, +body}:
91      m ++ " " ++ p ++ " HTTP/1.1\r\nHost: " ++ host ++ "\r\n"
92        ++ Http.render_headers(hs)
93        ++ "Content-Length: " ++ U32.show(U.Utf8.size(body)) ++ "\r\n\r\n" ++ body

Uses (6)

Used by (1)