gluegun/response
HTTP response values collected by gluegun/client.
The response field is a standard gleam/http/response.Response.
Trailers and ordered informational 1xx responses remain alongside it.
Selecting only response excludes that metadata; keep the outer value
when you need the complete exchange.
Import gleam/http/response as http_response for standard response helpers.
Types
A standard informational 1xx response with no body.
pub type Informational =
response.Response(Nil)
Full HTTP response collected from a Gun stream.
The client collects a Response(BitArray) with the full body in memory.
Use standard response helpers on response, then update that field to keep
trailers and informational responses when transforming the body.
pub type Response(body) {
Response(
response: response.Response(body),
trailers: List(#(String, String)),
informational: List(response.Response(Nil)),
)
}
Constructors
-
Response( response: response.Response(body), trailers: List(#(String, String)), informational: List(response.Response(Nil)), )
Values
pub fn body_text(
response: Response(BitArray),
) -> Result(String, error.GluegunError)
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 headers(
response: Response(body),
) -> List(#(String, String))
Return final response headers.
pub fn informational(
response: Response(body),
) -> List(response.Response(Nil))
Return informational 1xx responses received before the final response.