emerging-ezhttp Releases (14): 0.21.0.0 0xedb2120a04a47dc18c3a756ec7c62750 indexed https://jend.leeeet.dev/files.txt?path=emerging-ezhttp@0.21.0.0 0.20.0.0 0xdc8b9e3a3b68c4b632d5e290f8608324 unindexed https://jend.leeeet.dev/files.txt?path=emerging-ezhttp@0.20.0.0 0.19.0.0 0x60f672946f1b37cf58e2c05154bec295 unindexed https://jend.leeeet.dev/files.txt?path=emerging-ezhttp@0.19.0.0 0.18.0.0 0x9aad1f0de4523b34b9bfb69ebb80e11a unindexed https://jend.leeeet.dev/files.txt?path=emerging-ezhttp@0.18.0.0 0.17.0.0 0x2c3360c0ff9d38b16f7c5d3da25532d7 unindexed https://jend.leeeet.dev/files.txt?path=emerging-ezhttp@0.17.0.0 0.16.0.0 0x1bc4d92e7c1f4dd1a49d87ad449b730b unindexed https://jend.leeeet.dev/files.txt?path=emerging-ezhttp@0.16.0.0 0.15.0.0 0x1f543f6efa42f1e63aa3ace2f0eddab7 unindexed https://jend.leeeet.dev/files.txt?path=emerging-ezhttp@0.15.0.0 0.14.0.0 0xa4d47e5f0f6044ac1a983d1b051fa47a unindexed https://jend.leeeet.dev/files.txt?path=emerging-ezhttp@0.14.0.0 0.13.0.0 0xd3f9c1f02240edb63fd4a109ceb8fa74 unindexed https://jend.leeeet.dev/files.txt?path=emerging-ezhttp@0.13.0.0 0.12.0.0 0x3dbb16bf4e0314e097c69a222f1a4d08 unindexed https://jend.leeeet.dev/files.txt?path=emerging-ezhttp@0.12.0.0 0.11.0.0 0x86ed7e1c3039a36756163ddcb16e3a95 unindexed https://jend.leeeet.dev/files.txt?path=emerging-ezhttp@0.11.0.0 0.10.0.0 0xa22bee008c725452ca25c990ed2e8867 unindexed https://jend.leeeet.dev/files.txt?path=emerging-ezhttp@0.10.0.0 0.9.0.0 0xf0cabef12a69d5a23f62f89a75e1a7ba invalid https://jend.leeeet.dev/files.txt?path=emerging-ezhttp@0.9.0.0 expected a fresh constructor name (duplicate declaration: Text) At https://jend.leeeet.dev/read.txt?path=emerging-ezhttp@0.9.0.0/src/body.bend&start_line=9. Files that do not load: main.bend, src/auth.bend, src/body.bend, src/cache.bend, src/client.bend and 5 more. 0.8.0.0 0xf1c957a470368870a6d1d62a8c0cbe32 invalid https://jend.leeeet.dev/files.txt?path=emerging-ezhttp@0.8.0.0 expected a fresh constructor name (duplicate declaration: Text) At https://jend.leeeet.dev/read.txt?path=emerging-ezhttp@0.8.0.0/src/body.bend&start_line=9. Files that do not load: main.bend, src/auth.bend, src/body.bend, src/cache.bend, src/client.bend and 4 more. Definitions (909, 1 to 100 shown): EmergingEzhttp.parse_url (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=parse_url) # URL parse re-export def parse_url(url: String) -> Url.Loc: # noqa: L001 re-export of Url.parse EmergingEzhttp.quote_path (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=quote_path) # percent-encode a path (RFC 3986 §2.1), as Python's urllib.parse.quote(text): # unreserved characters and "/" stay, every other character becomes %XX per # UTF-8 byte, upper-case hex (SPEC.md HTTP-URL) def quote_path(text: String) -> String: # noqa: L001 re-export of Pct.quote (the path form) EmergingEzhttp.quote_component (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=quote_component) # percent-encode a path segment, query key or value (RFC 3986 §2.1), as # urllib.parse.quote(text, safe=""): like quote_path, but "/" becomes %2F def quote_component(text: String) -> String: # noqa: L001 re-export of Pct.quote (the component form) EmergingEzhttp.unquote (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=unquote) # percent-decode a string as urllib.parse.unquote: %XX escapes (either case) # become bytes, decoded as UTF-8 with U+FFFD for bytes that are not; an escape # that is not two hex digits is kept as written, and characters outside ASCII # are kept (SPEC.md HTTP-QS) def unquote(text: String) -> String: # noqa: L001 re-export of Qs.unquote EmergingEzhttp.unquote_plus (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=unquote_plus) # percent-decode as urllib.parse.unquote_plus: `+` is a space, then unquote def unquote_plus(text: String) -> String: # noqa: L001 re-export of Qs.unquote.plus EmergingEzhttp.quote_plus (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=quote_plus) # percent-encode as urllib.parse.quote_plus: as quote_component, but a space # is written `+` (so `+` itself is %2B) def quote_plus(text: String) -> String: # noqa: L001 re-export of Qs.quote.plus EmergingEzhttp.Kv (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=Kv) # a name and a value, reusable: a query field or a cookie, written (k, v) def Kv() -> Data: # noqa: L001 re-export of the type Qs.Kv EmergingEzhttp.urlencode (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=urlencode) # a query string from name and value pairs, as urllib.parse.urlencode(pairs): # `name=value` with both quote_plus'd, joined by `&`, in order def urlencode(pairs: List<&2, Qs.Kv()>) -> String: # noqa: L001 re-export of Qs.urlencode EmergingEzhttp.parse_query (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=parse_query) # a query string's name and value pairs, as # urllib.parse.parse_qsl(text, keep_blank_values=True): split on `&`, empty # pieces skipped, each cut at its first `=` (a piece without one is a name # with an empty value), both unquote_plus'd. Every pair is kept, in order, # duplicate names included; query_get reads the last one def parse_query(text: String) -> List<&2, Qs.Kv()>: # noqa: L001 re-export of Qs.parse EmergingEzhttp.query_get (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=query_get) # the value of the last pair with this name (names compared exactly), none # when no pair has it: last-wins, as a dict(parse_qsl(...)) would be def query_get(pairs: List<&2, Qs.Kv()>, name: String) -> Maybe<&2, String>: # noqa: L001 re-export of Qs.get EmergingEzhttp.parse_response (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=parse_response) # response parse re-export; `raw` is octets, one character each (SPEC.md # HTTP-BODY) def parse_response(raw: String) -> Http.Reply: # noqa: L001 re-export of Http.parse EmergingEzhttp.parse_response_to (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=parse_response_to) # a response as the client reads it for a request with this method: interim # 1xx heads skipped, and no body for HEAD or a 1xx, 204 or 304 status, # whatever Content-Length says (SPEC.md HTTP-CLI-9) def parse_response_to(method: String, raw: String) -> Http.Reply: # noqa: L001 re-export of Http.parse.to EmergingEzhttp.reason_phrase (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=reason_phrase) # the reason phrase of a response's status line (RFC 9112 §4), read from the # head parse_response_to stops at; empty when there is none (SPEC.md # HTTP-CLI-11) def reason_phrase(raw: String) -> String: # noqa: L001 re-export of Http.phrase.to EmergingEzhttp.parse_request (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=parse_request) # request parse re-export (server inbound) def parse_request(raw: String) -> Http.Request: # noqa: L001 re-export of Http.ask EmergingEzhttp.format_response (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=format_response) # format a response message (server outbound) def format_response(status: U32, headers: List<&2, Http.Header>, body: String) # noqa: L001 re-export of Http.respond -> String: EmergingEzhttp.empty_body (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=empty_body) # empty request body def empty_body() -> Body.Body: # noqa: L001 re-export of Body.body.empty EmergingEzhttp.text_body (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=text_body) # UTF-8 text request body def text_body(text: String) -> Body.Body: # noqa: L001 re-export of Body.body.text EmergingEzhttp.octets_body (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=octets_body) # packed octets request body (bend-kit-bytes Bytes), sent unchanged def octets_body(bytes: Bytes.Bytes) -> Body.Body: # noqa: L001 re-export of Body.body.octets EmergingEzhttp.octets_list_body (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=octets_list_body) # octets request body from a list of octet values (each 0..255) def octets_list_body(bs: List<&2, U32>) -> Body.Body: # noqa: L001 re-export of Body.body.list EmergingEzhttp.form_field (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=form_field) # a multipart/form-data text field (RFC 7578) def form_field(name: String, value: String) -> Form.Upload: # noqa: L001 re-export of Form.form.field EmergingEzhttp.form_file (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=form_file) # a multipart/form-data file part: field name, filename, content type and the # file's bytes (packed Bytes, sent unchanged) def form_file(name: String, filename: String, ctype: String, # noqa: L001 re-export of Form.form.file bytes: Bytes.Bytes) -> Form.Upload: EmergingEzhttp.form_body (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=form_body) # a multipart/form-data body (RFC 7578) with this boundary: the Content-Type # field value to send and an octet body, or why the boundary cannot be used # (SPEC.md HTTP-FORM) def form_body(boundary: String, parts: List<&1, Form.Upload>) -> Form.Form: # noqa: L001 re-export of Form.form.body EmergingEzhttp.encode (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=encode) # BYO JSON (or any codec): encode a value with the caller's to_text def encode(~A: Data, ~to_text: A -> String, value: A) -> Body.Body: # noqa: L001 re-export of Body.body.encode EmergingEzhttp.decode (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=decode) # BYO JSON (or any codec): decode body text with the caller's from_text def decode( # noqa: L001 re-export of Body.body.decode ~A: Data, ~from_text: String -> Maybe<&2, A>, text: String ) -> Maybe<&2, A>: EmergingEzhttp.bearer (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=bearer) # Bearer token header helper def bearer(token: String) -> Http.Header: # noqa: L001 re-export of client.bearer = Auth.auth.bearer EmergingEzhttp.basic (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=basic) # Basic credentials header (RFC 7617) def basic(user: String, password: String) -> Http.Header: # noqa: L001 re-export of client.basic = Auth.auth.basic EmergingEzhttp.set_cookie (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=set_cookie) # Set-Cookie header from a parsed cookie (RFC 6265) def set_cookie(cookie: Cookie.Cookie) -> Http.Header: # noqa: L001 re-export of Cookie.cookie.set EmergingEzhttp.parse_cookie (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=parse_cookie) # parse one Set-Cookie field value def parse_cookie(line: String) -> Maybe<&2, Cookie.Cookie>: # noqa: L001 re-export of Cookie.cookie.parse EmergingEzhttp.cookie_header (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=cookie_header) # Cookie request header for a list of cookies def cookie_header(cs: List<&2, Cookie.Cookie>) -> Http.Header: # noqa: L001 re-export of Cookie.cookie.request EmergingEzhttp.cache_control (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=cache_control) # parse a Cache-Control field value (RFC 9111) def cache_control(value: String) -> Cache.Cc: # noqa: L001 re-export of Cache.cache.parse EmergingEzhttp.fresh (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=fresh) # freshness of a Cache-Control value at an age in seconds def fresh(value: String, age: Nat) -> Bool: # noqa: L001 Cache.cache.fresh of Cache.cache.parse EmergingEzhttp.cors_reply (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=cors_reply) # CORS preflight or simple headers on a handler reply def cors_reply( # noqa: L001 re-export of Cors.cors.on cfg: Cors.Cfg, req: Http.Request, reply: Http.Reply ) -> Http.Reply: EmergingEzhttp.html_escape (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=html_escape) # escape text for HTML as markupsafe and Jinja's autoescape do: & < > " ' as # & < > " ', every other character as itself def html_escape(text: String) -> String: # noqa: L001 re-export of Html.escape EmergingEzhttp.html_unescape (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=html_unescape) # HTML character references back to characters, as Python's html.unescape: # decimal and hex numeric references (with the HTML Standard's replacements) # and the HTML Standard's 2231 named references, the legacy ones also without # `;`; anything that is not a reference is kept as written (SPEC.md HTTP-REF) def html_unescape(text: String) -> String: # noqa: L001 re-export of Unescape.unescape EmergingEzhttp.cookie_from_set_cookies (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=cookie_from_set_cookies) # the Cookie header value to send back after these Set-Cookie field values # (RFC 6265 §5.2, §5.4): each one's name=value, attributes ignored; a later # cookie with the same name replaces the earlier one's value in its place; # `name=value` pairs joined by `; ` (SPEC.md HTTP-CK) def cookie_from_set_cookies(values: List<&2, String>) -> String: # noqa: L001 re-export of Echo.echo EmergingEzhttp.cookie_from_headers (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=cookie_from_headers) # the same, from a response's header fields (its Set-Cookie fields, in order) def cookie_from_headers(headers: List<&2, Http.Header>) -> String: # noqa: L001 Echo.echo of Echo.values EmergingEzhttp.http.get (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.get) # GET with no extra headers def http.get(url: String) -> IO(Client.Response): EmergingEzhttp.http.get_with (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.get_with) # GET with headers def http.get_with(url: String, headers: List<&2, Http.Header>) -> IO(Client.Response): EmergingEzhttp.http.get_opts (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.get_opts) # GET with headers and a timeout in milliseconds that bounds connecting, # sending and receiving; with `follow`, redirects are followed (GET only, at # most 10 hops, see src/redirect.bend) def http.get_opts( url: String, headers: List<&2, Http.Header>, timeout_ms: U32, follow: Bool ) -> IO(Client.Response): EmergingEzhttp.http.request_opts (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.request_opts) # a request with any method, headers, a body and a timeout in milliseconds # that bounds connecting, sending and receiving; with `follow`, a GET follows # redirects (at most 10 hops, see src/redirect.bend) and every other method # answers a redirect as its response def http.request_opts( method: String, url: String, headers: List<&2, Http.Header>, body: Body.Body, timeout_ms: U32, follow: Bool ) -> IO(Client.Response): EmergingEzhttp.http.post_opts (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.post_opts) # POST with headers, a body and a timeout in milliseconds; redirects are not # followed def http.post_opts( url: String, headers: List<&2, Http.Header>, body: Body.Body, timeout_ms: U32 ) -> IO(Client.Response): EmergingEzhttp.http.put_opts (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.put_opts) # PUT with headers, a body and a timeout in milliseconds; redirects are not # followed def http.put_opts( url: String, headers: List<&2, Http.Header>, body: Body.Body, timeout_ms: U32 ) -> IO(Client.Response): EmergingEzhttp.http.delete_opts (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.delete_opts) # DELETE with headers, a body and a timeout in milliseconds; redirects are # not followed def http.delete_opts( url: String, headers: List<&2, Http.Header>, body: Body.Body, timeout_ms: U32 ) -> IO(Client.Response): EmergingEzhttp.http.timed_out (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.timed_out) # whether a response is an exchange that ran out of time def http.timed_out(r: Client.Response) -> Bool: EmergingEzhttp.body_text (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=body_text) # a response body's octets (a Response's `bytes`) decoded as UTF-8, done only # when called (SPEC.md HTTP-BODY-4) def body_text(bytes: Bytes.Bytes) -> String: # noqa: L001 re-export of Client.client.text EmergingEzhttp.http.head (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.head) # HEAD with no extra headers def http.head(url: String) -> IO(Client.Response): EmergingEzhttp.http.head_with (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.head_with) # HEAD with headers def http.head_with(url: String, headers: List<&2, Http.Header>) -> IO(Client.Response): EmergingEzhttp.http.post (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.post) # POST with a body and no extra headers def http.post(url: String, body: Body.Body) -> IO(Client.Response): EmergingEzhttp.http.post_with (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.post_with) # POST with headers and a body def http.post_with( url: String, headers: List<&2, Http.Header>, body: Body.Body ) -> IO(Client.Response): EmergingEzhttp.http.put (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.put) # PUT with a body and no extra headers def http.put(url: String, body: Body.Body) -> IO(Client.Response): EmergingEzhttp.http.put_with (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.put_with) # PUT with headers and a body def http.put_with(url: String, headers: List<&2, Http.Header>, body: Body.Body) -> IO(Client.Response): EmergingEzhttp.http.delete (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.delete) # DELETE with a body and no extra headers def http.delete(url: String, body: Body.Body) -> IO(Client.Response): EmergingEzhttp.http.delete_with (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.delete_with) # DELETE with headers and a body def http.delete_with( url: String, headers: List<&2, Http.Header>, body: Body.Body ) -> IO(Client.Response): EmergingEzhttp.http.options (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.options) # OPTIONS with no extra headers def http.options(url: String) -> IO(Client.Response): EmergingEzhttp.http.options_with (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.options_with) # OPTIONS with headers def http.options_with(url: String, headers: List<&2, Http.Header>) -> IO(Client.Response): EmergingEzhttp.http.serve (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.serve) # listen on host:port and serve up to `limit` connections def http.serve( ~handle: Http.Request -> Http.Reply, host: String, port: U32, limit: U32 ) -> IO(Unit): EmergingEzhttp.http.serve_io (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.serve_io) # listen on host:port and serve up to `limit` connections with a handler that # does IO; a failed connection is logged and the next one is served def http.serve_io( ~handle: Http.Request -> IO(Http.Reply), host: String, port: U32, limit: U32 ) -> IO(Unit): EmergingEzhttp.http.serve_forever (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.serve_forever) # listen on host:port and serve with an IO handler until the process stops @unsafe def http.serve_forever( ~handle: Http.Request -> IO(Http.Reply), host: String, port: U32 ) -> IO(Unit): EmergingEzhttp.http.serve_with (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.serve_with) # listen on host:port and serve up to `limit` connections, each on its own # fork and at most `max` at once (0: no limit), calling a pure handler with # `ctx` and the request (Server.Req: text, and its body's octets); returns # once every connection is closed (SPEC.md HTTP-SRV, HTTP-TRUST-2) def http.serve_with( ~C: Data, ~handle: C -> Server.Req -> Server.Answer, ctx: C, host: String, port: U32, limit: U32, … EmergingEzhttp.http.serve_io_with (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.serve_io_with) # the same with a handler that does IO def http.serve_io_with( ~C: Data, ~handle: C -> Server.Req -> IO(Server.Answer), ctx: C, host: String, port: U32, limit: U32, max: U32 ) -> IO(Unit): EmergingEzhttp.http.serve_forever_with (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.serve_forever_with) # the same with no limit: it serves until the process is stopped @unsafe def http.serve_forever_with( ~C: Data, ~handle: C -> Server.Req -> IO(Server.Answer), ctx: C, host: String, port: U32, max: U32 ) -> IO(Unit): EmergingEzhttp.text_reply (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=text_reply) # a reply with a text body, written as UTF-8 def text_reply( # noqa: L001 constructor of Server.Answer, which holds Bytes status: U32, headers: List<&2, Http.Header>, body: String) -> Server.Answer: EmergingEzhttp.octets_reply (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=octets_reply) # a reply whose body is packed octets, written unchanged def octets_reply( # noqa: L001 constructor of Server.Answer, which holds Bytes status: U32, headers: List<&2, Http.Header>, bytes: Bytes.Bytes) -> Server.Answer: EmergingEzhttp.stream_reply (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=stream_reply) # a reply streamed chunked: each chunk the channel gives is written as it # comes, and the body ends when the channel is closed def stream_reply( # noqa: L001 constructor of Server.Answer, which holds a channel status: U32, headers: List<&2, Http.Header>, chunks: Chan(Bytes.Bytes)) -> Server.Answer: EmergingEzhttp.http.serve_once (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/main.bend&name=http.serve_once) # listen on host:port, serve one connection, then stop def http.serve_once( ~handle: Http.Request -> Http.Reply, host: String, port: U32 ) -> IO(Unit): Auth.auth.bearer (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/auth.bend&name=auth.bearer) # Authorization: Bearer … (RFC 6750) def auth.bearer(token: String) -> Http.Header: Auth.auth.basic (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/auth.bend&name=auth.basic) # Authorization: Basic … (RFC 7617, credentials are RFC 4648 Base64) def auth.basic(user: String, password: String) -> Http.Header: B64.Phase (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/b64.bend&name=Phase) # how many octets of the current quantum are still missing type Phase is Data: Need3{} Need2{first: U32} Need1{first: U32, second: U32} B64.b64.table (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/b64.bend&name=b64.table) # RFC 4648 §4 alphabet, index 0 is `A` def b64.table() -> String: B64.b64.char (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/b64.bend&name=b64.char) # the character at a 0..63 index, `A` when the index is out of the table def b64.char(m: Maybe<&2, Char>) -> Char: B64.b64.at (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/b64.bend&name=b64.at) # one 6-bit value as an alphabet character def b64.at(+n: U32) -> Char: B64.b64.pack (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/b64.bend&name=b64.pack) # 24 bits from three octets def b64.pack(+a: U32, +b: U32, +c: U32) -> U32: B64.b64.tail.more (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/b64.bend&name=b64.tail.more) # the last two characters when the quantum was short def b64.tail.more(+n: U32, left: Nat) -> String: B64.b64.tail (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/b64.bend&name=b64.tail) # four characters from a packed quantum; pad is how many `=` to write def b64.tail(+n: U32, pad: Nat) -> String: B64.b64.quad (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/b64.bend&name=b64.quad) # one quantum as four characters def b64.quad(+a: U32, +b: U32, +c: U32, pad: Nat) -> String: B64.b64.end (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/b64.bend&name=b64.end) # padding for a quantum that ended early def b64.end(phase: Phase) -> String: B64.b64.go (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/b64.bend&name=b64.go) # octets to Base64, three at a time (RFC 4648 §4) def b64.go(bs: List<&2, U32>, phase: Phase) -> String: B64.b64.bytes (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/b64.bend&name=b64.bytes) # code points of a string, one octet each (credentials are ASCII) def b64.bytes(s: String) -> List<&2, U32>: B64.b64.encode (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/b64.bend&name=b64.encode) # Base64 of a string (RFC 4648 §4) def b64.encode(s: String) -> String: Body.Body (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/body.bend&name=Body) # what rides in a request: nothing, text, or raw octets type Body is Type: Empty{} Plain{text: String} Octets{bytes: Bytes.Bytes} Body.Shape (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/body.bend&name=Shape) # what the request text needs to know of a body: its text, or how many # octets follow it (SPEC.md HTTP-CLI-10) type Shape is Data: ShapeText{text: String} ShapeOctets{n: U32} Body.body.sized (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/body.bend&name=body.sized) # an octets body's count: its shape, and the octets handed back def body.sized(r: Bytes.Bytes & U32) -> Shape & Bytes.Bytes: Body.body.shape (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/body.bend&name=body.shape) # 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 body.shape(b: Body) -> Shape & Bytes.Bytes: Body.octets.chars (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/body.bend&name=octets.chars) # octets, one character each (each 0..255), from a list of their values def octets.chars(bs: List<&2, U32>) -> String: Body.body.empty (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/body.bend&name=body.empty) # empty body def body.empty() -> Body: Body.body.text (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/body.bend&name=body.text) # UTF-8 text body def body.text(s: String) -> Body: Body.body.octets (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/body.bend&name=body.octets) # octets body def body.octets(bytes: Bytes.Bytes) -> Body: Body.body.list (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/body.bend&name=body.list) # an octets body from a list of octet values (each 0..255; a value past 255 # keeps its low 8 bits) def body.list(bs: List<&2, U32>) -> Body: Body.body.encode (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/body.bend&name=body.encode) # BYO encode: any value to a text body via the caller's encoder def body.encode(~A: Data, ~to_text: A -> String, value: A) -> Body: Body.body.decode (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/body.bend&name=body.decode) # BYO decode: body text to a value via the caller's decoder def body.decode(~A: Data, ~from_text: String -> Maybe<&2, A>, s: String) -> Maybe<&2, A>: Cache.Cc (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/cache.bend&name=Cc) # the directives this module records type Cc is Data: Cc{ no_store: Bool no_cache: Bool public: Bool private: Bool max_age: String expires: String } Cache.cache.empty (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/cache.bend&name=cache.empty) # no directives def cache.empty() -> Cc: Cache.cache.store (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/cache.bend&name=cache.store) # set no-store def cache.store(c: Cc) -> Cc: Cache.cache.revalidate (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/cache.bend&name=cache.revalidate) # set no-cache def cache.revalidate(c: Cc) -> Cc: Cache.cache.pub (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/cache.bend&name=cache.pub) # set public def cache.pub(c: Cc) -> Cc: Cache.cache.priv (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/cache.bend&name=cache.priv) # set private def cache.priv(c: Cc) -> Cc: Cache.cache.age (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/cache.bend&name=cache.age) # set max-age text def cache.age(c: Cc, age: String) -> Cc: Cache.cache.expires (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/cache.bend&name=cache.expires) # set the Expires header text def cache.expires(c: Cc, when: String) -> Cc: Cache.cache.one.private (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/cache.bend&name=cache.one.private) # private, or leave the directive unrecognized def cache.one.private(c: Cc, _name: String, _value: String, hit: Bool) -> Cc: Cache.cache.one.public (https://jend.leeeet.dev/definition.txt?path=emerging-ezhttp@0.21.0.0/src/cache.bend&name=cache.one.public) # public def cache.one.public(c: Cc, +name: String, value: String, hit: Bool) -> Cc: More: https://jend.leeeet.dev/packages/emerging-ezhttp.txt?definitions_offset=100