HTTP Request

Specify Method by -X


curl -X <METHOD> <URI>

By default, it uses GET method


# same as 
curl -X GET

Use Post simply by:

curl -X POST


Get entire document of the website in terminal



curl -X POST

More complex, pass data, -d and header -H to server. Below shows POST with json body

curl -d '{"option": "value", "something": "anothervalue"}' \
-H "Content-Type: application/json" \ 

HTTP Headers

Inspect all details of header by --verbose

curl -v

# same as 
curl -verbose

Only see the header by -I

curl -I

Get the body along with response header with -i

It’s similar to --verbose but contains less.

Response header is usually omitted. Use -i to include it

# full name
curl -include
curl -i

Set referer

An HTTP request may include a ‘referer’ field (yes it is misspelled), which can be used to tell from which URL the client got to this particular resource.

curl --referer

Set User-agnet

curl --user-agent "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" [URL]

Store the response to a file, like wget

With its origin file name

curl -O

Give a new name

curl -o output.html