Reference · reference

http module

2 min read · 2026-09-02 · config-weave 0.1.0

use http is an HTTP client. It is built on rustls, so it has no dependency on the system TLS library. Every function returns Result[…, string] and takes an options Value as its last argument. The options argument is required: pass Value::Null for the defaults, or a Value::Map with any of the keys below. A response with an error status is still Ok; inspect status.

OptionTypeMeaning
headersmap of stringrequest headers
timeoutint or floatseconds before the request is abandoned
redirectsboolfollow redirects, default true

HttpResponse

rust
struct HttpResponse {
    status: int,
    body: string,
    headers: Map[string, string],
}

The result of get and post.

get

rust
http::get(url: string, opts: Value) -> Result[HttpResponse, string]

Sends a GET request and returns the response.

post

rust
http::post(url: string, body: string, opts: Value) -> Result[HttpResponse, string]

Sends body in a POST request and returns the response. Set the content type with a headers entry.

download

rust
http::download(url: string, dest: string, opts: Value) -> Result[int, string]

Fetches url and writes the body to the file at dest. It returns the number of bytes written. Pair it with the archive module to unpack what was fetched.

rust
use http
use value

let n = http::download("https://example.org/tool.tar.gz", "/tmp/tool.tar.gz", Value::Null)?