Modular Computers the manual GitHub

curl

curl: make an HTTP request.

Synopsis

curl [-X method] [-H header]… [-d data] [-o file] [-iIfLs] [-A agent] url

Description

curl makes an HTTP or HTTPS request through the computer’s internet card and writes what comes back to standard output. A URL without a scheme is http://’s.

The card reaches only the public internet: never the server’s own machine or network (the server’s settings may allow more, or less). It writes the headers HTTP needs itself (Host, Content-Length, Connection); a request can’t set those.

Options

-X method
GET, HEAD, POST, PUT, DELETE, PATCH or OPTIONS.
-H ‘Name: value’
A header; again for more.
-d data
A body: the request is a POST, with Content-Type: application/x-www-form-urlencoded unless a header says otherwise. Again for more, joined with &.
-o file
Writes to file instead.
-i
Writes the response’s status and headers first.
-I
Makes a HEAD request: only its status and headers.
-L
Follows redirects.
-f
Fails on an HTTP error (400 or more): no output, exit 22.
-s
Silent: no messages.
-A agent
The User-Agent header.

Exit status

0 when done; 2 for bad usage; 6 for an unknown host; 7 when it couldn’t connect (refused, or the server forbids the address); 22 for an HTTP error with -f; 23 when the output can’t be written; 28 when it timed out; 47 for too many redirects.

Examples

curl https://example.com/
curl -i -X POST -H 'Content-Type: application/json' -d '{"a":1}' https://example.com/api
curl -sL -o page.html example.com

Notes

Real curl speaks many protocols and has hundreds of options; mcos’s speaks HTTP and HTTPS, with these.

See also

wget(1)