Skip to content

Std.Http.Response

type Response(status: Int, headers: List[(String, String)], body: String)

A response. The headers of a response received by send have lower-case names sorted by name; values of the same name are joined with , , except that each set-cookie is its own pair. An HTTP service sends the headers in the written order.

  • status: Int
  • headers: List[(String, String)]
  • body: String
error UnexpectedStatus(status: Int, body: String)

The status is not 2xx (require_ok).

  • status: Int
  • body: String
fn new(status: Int, body: String) -> Response

A response with no headers.

fn add_header(res: Response, name: String, value: String) -> Response

Adds a header after the ones already in res.

fn header(res: Response, name: String) -> Option[String]

The first value of the header name, compared without case.

fn header_values(res: Response, name: String) -> List[String]

All values of the header name in order, compared without case. Not named headers, the field (E3109).

fn require_ok(res: Response) -> Response fails UnexpectedStatus

res if its status is 2xx, otherwise fails with UnexpectedStatus.