HTTP headers
To set custom headers you can use the Header:Value
notation:
- $ http example.org User-Agent:Bacon/1.0 'Cookie:valued-visitor=yes;foo=bar' \
- X-Foo:Bar Referer:https://httpie.org/
- GET / HTTP/1.1
- Accept: */*
- Accept-Encoding: gzip, deflate
- Cookie: valued-visitor=yes;foo=bar
- Host: example.org
- Referer: https://httpie.org/
- User-Agent: Bacon/1.0
- X-Foo: Bar
Default request headers
There are a couple of default headers that HTTPie sets:
- GET / HTTP/1.1
- Accept: */*
- Accept-Encoding: gzip, deflate
- User-Agent: HTTPie/<version>
- 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:
:
- $ http httpbin.org/headers Accept: User-Agent:
To send a header with an empty value, use Header;
:
- $ 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).
- $ http --max-headers=100 httpbin.org/get