Skip to content
Welcome to the Gluegun documentation!

gluegun/response

HTTP response values collected by gluegun/client.

A response contains the final status, headers, full body, trailers, and any informational 1xx responses seen before the final response.

Informational 1xx response represented by status and headers.

pub type Informational {
Informational(
status: Int,
headers: List(#(String, String))
)
}

Full HTTP response collected from a Gun stream.

Accessors: status, headers, body, body_text, trailers, informational. The body is held fully in memory.

pub type Response

Return the full collected response body.

pub fn body(Response) -> BitArray

Decode the collected response body as UTF-8 text.

Returns DecodeError("Response body is not valid UTF-8") if the bytes are not valid UTF-8. For binary responses use body directly.

pub fn body_text(Response) -> Result(String, error.GluegunError)

Return final response headers.

pub fn headers(Response) -> List(#(String, String))

Return informational 1xx responses received before the final response.

pub fn informational(Response) -> List(Informational)

Return the final response status.

pub fn status(Response) -> Int

Return response trailers.

pub fn trailers(Response) -> List(#(String, String))