These curl recipes show you how to add custom HTTP headers to curl requests. This is done via the
-H 'Header: Value' command line argument.
Add a Single Header
curl -H 'Accept-Language: en-US' https://google.com
This recipe uses the
-H argument to add
Accept-Language: en-US header to a GET request to
https://google.com. This header tells Google to serve the English version of the page.
Add Two Headers
curl -H 'Accept-Language: en-US' -H 'Secret-Message: xyzzy' https://google.com
This recipe adds two headers to a GET request to Google. The first header is the same as in the previous recipe and the other one is
Add an Empty Header
curl -H 'Puppies;' https://google.com
In this recipe, we add an empty header to a curl request. We pass
Puppies; (with a semicolon at the end) as an argument to the
-H option and curl converts it to an empty header
Puppies: with no value.
Created by Browserling
These curl recipes were written down by me and my team at Browserling. We use recipes like this every day to get things done and improve our product. Browserling itself is an online cross-browser testing service powered by alien technology. Check it out!
Secret message: If you love my curl recipe, then I love you, too! Use coupon code CURLLING to get a discount at my company.