response
HTTP responses
A Response is a record, in the HTTP interface package nanyx.http.core (see client); the console host’s
prelude brings it into every module of a program. Its headers are named in lower case, and Response.header finds
one whatever case it is asked for in:
match http.get("https://example.com")
| #some(response) -> println(Response.header(response, "Content-Type"))
| #error(_) -> println("The request failed")
Reference
HTTP responses.
A Response is a record: its status, its headers, each a name in lower case and a value, and
its body, as text. A client gets one from http.send; a handler makes one, with
Response.text or as a record.
Response
type Response = (status: int, headers: list((string, string)), body: string)
An HTTP response: its status, as 200, its headers, each a name in lower case and a value, in
the order they came, and its body.
Response.text
def Response.text: int, string -> Response
A response with the status status and the text body, as plain text in UTF-8.
Response.header
def Response.header: Response, string -> #some(string) | #notFound
The value of the first header of response named name, whatever its case:
Response.header(r, "Content-Type").