HTTP headers

To set custom headers you can use the Header:Value notation:

  1. $ http example.org User-Agent:Bacon/1.0 'Cookie:valued-visitor=yes;foo=bar' \
  2. X-Foo:Bar Referer:https://httpie.org/
  1. GET / HTTP/1.1
  2. Accept: */*
  3. Accept-Encoding: gzip, deflate
  4. Cookie: valued-visitor=yes;foo=bar
  5. Host: example.org
  6. Referer: https://httpie.org/
  7. User-Agent: Bacon/1.0
  8. X-Foo: Bar

Default request headers

There are a couple of default headers that HTTPie sets:

  1. GET / HTTP/1.1
  2. Accept: */*
  3. Accept-Encoding: gzip, deflate
  4. User-Agent: HTTPie/<version>
  5. Host: <taken-from-URL>

Any of these except Host can be overwritten and some of them unset.

Empty headers and header un-setting

To unset a previously specified header(such a one of the default headers), use Header::

  1. $ http httpbin.org/headers Accept: User-Agent:

To send a header with an empty value, use Header;:

  1. $ http httpbin.org/headers 'Header;'

Limiting response headers

The —max-headers=n options allows you to control the number of headersHTTPie reads before giving up (the default 0, i.e., there’s no limit).

  1. $ http --max-headers=100 httpbin.org/get