Skip to content

http

Make HTTP requests (like curl).

Synopsis

tofu http <url> [flags]

Description

Perform HTTP requests with support for different methods, headers, and data.

Flags

Flag Short Description Default
--method -X HTTP method GET
--headers -H Custom headers (can repeat)
--data -d POST data
--output -o Write output to file
--follow-redirects -L Follow redirects false
--verbose -v Verbose output false
--insecure -k Allow insecure SSL connections false

Examples

Simple GET request:

tofu http https://api.example.com/data

POST with data:

tofu http -X POST -d '{"name":"test"}' https://api.example.com/users

POST with data (auto-detects POST method):

tofu http -d '{"key":"value"}' https://api.example.com

Set custom headers:

tofu http -H "Authorization: Bearer token123" -H "Content-Type: application/json" https://api.example.com

Save response to file:

tofu http -o response.json https://api.example.com/data

Follow redirects:

tofu http -L https://example.com

Verbose mode (show headers):

tofu http -v https://example.com

Allow self-signed certificates:

tofu http -k https://localhost:8443

Verbose Output

> GET /api/users HTTP/1.1
> Host: api.example.com
> User-Agent: tofu/http
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Length: 42
<
{"users": [...]}