gluegun/client
High-level HTTP helpers for existing Gun connections.
These helpers collect a full HTTP/1.1 or HTTP/2 response — status,
headers, body, trailers, and any informational 1xx responses — into a
response.Response. The body is held fully in memory; use the lower-level
gluegun/request and gluegun/message APIs for streaming or very large
responses.
Protocol messages for server push, upgrades, and WebSockets are rejected
with InvalidMessage. Use the lower-level gluegun/message API for
those flows.
If collection fails, these helpers attempt to cancel the failed stream and drain its queued messages, then return the original error. They keep other streams and the connection open. Cancellation is asynchronous: messages in transit can arrive after the drain. For strict mailbox isolation, use the low-level API in a separate receiving process.
Request
Section titled “Request”A buildable HTTP request: method, path, headers, body, options, and timeout.
pub type RequestFunctions
Section titled “Functions”add_headers
Section titled “add_headers”Append request headers.
pub fn add_headers( Request, headers: List(#(String, String))) -> Requestdelete
Section titled “delete”Send DELETE on an open connection and collect the full response.
pub fn delete( internal.Connection, String, List(#(String, String)), connection.Timeout) -> Result(response.Response, error.GluegunError)Send GET on an open connection and collect the full response.
pub fn get( internal.Connection, String, List(#(String, String)), connection.Timeout) -> Result(response.Response, error.GluegunError)Send HEAD on an open connection and collect the full response.
pub fn head( internal.Connection, String, List(#(String, String)), connection.Timeout) -> Result(response.Response, error.GluegunError)Start a new Request builder with the given method and path.
pub fn new( request.Method, String) -> RequestSend PATCH on an open connection and collect the full response.
pub fn patch( internal.Connection, String, List(#(String, String)), BitArray, connection.Timeout) -> Result(response.Response, error.GluegunError)Send POST on an open connection and collect the full response.
pub fn post( internal.Connection, String, List(#(String, String)), BitArray, connection.Timeout) -> Result(response.Response, error.GluegunError)Send PUT on an open connection and collect the full response.
pub fn put( internal.Connection, String, List(#(String, String)), BitArray, connection.Timeout) -> Result(response.Response, error.GluegunError)request_options
Section titled “request_options”Send OPTIONS on an open connection and collect the full response.
pub fn request_options( internal.Connection, String, List(#(String, String)), connection.Timeout) -> Result(response.Response, error.GluegunError)Send a built Request on an open connection and collect the response.
pub fn send( Request, connection: internal.Connection) -> Result(response.Response, error.GluegunError)with_body
Section titled “with_body”Replace the request body.
pub fn with_body( Request, body: BitArray) -> Requestwith_header
Section titled “with_header”Append a single request header.
pub fn with_header( Request, name: String, value: String) -> Requestwith_headers
Section titled “with_headers”Replace request headers.
pub fn with_headers( Request, headers: List(#(String, String))) -> Requestwith_options
Section titled “with_options”Replace low-level request options.
pub fn with_options( Request, options: request.RequestOptions) -> Requestwith_timeout
Section titled “with_timeout”Replace the request timeout.
pub fn with_timeout( Request, timeout: connection.Timeout) -> Request
