curl -H

From IndieWeb


curl -H is a command line option for the curl command that takes a single parameter of an extra header to include in the request.

Examples

curl -H "Accept: application/json"

To set multiple headers, repeat the option, e.g.:

curl -H "Accept: application/json" -H "Content-Type: application/json"

Language-Specific curl Equivalents

PHP

Equivalent in PHP for setting a header in a curl handler:

curl_setopt($c, CURLOPT_HTTPHEADER, ['Accept: application/json']);

Equivalent in PHP for setting multiple curl headers in a curl handler:

curl_setopt($c, CURLOPT_HTTPHEADER, ['Accept: application/json', 'Content-Type: application/json']);

IndieWeb Applications

There are several uses of setting HTTP headers within various IndieWeb building blocks

  • Sending an IndieAuth access token to a Micropub endpoint to create a post: curl -H "Authorization: Bearer XXXXXXXX"


See Also