Redirected output
HTTPie uses a different set of defaults for redirected output than forterminal output. The differences being:
- Formatting and colors aren't applied (unless
—pretty
is specified). - Only the response body is printed (unless one of the output options is set).
- Also, binary data isn't suppressed.
The reason is to make piping HTTPie's output to another programs anddownloading files work with no extra flags. Most of the time, only the rawresponse body is of an interest when the output is redirected.
Download a file:
- $ http example.org/Movie.mov > Movie.mov
Download an image of Octocat, resize it using ImageMagick, upload it elsewhere:
- $ http octodex.github.com/images/original.jpg | convert - -resize 25% - | http example.org/Octocats
Force colorizing and formatting, and show both the request and the response inless
pager:
- $ http --pretty=all --verbose example.org | less -R
The -R
flag tells less
to interpret color escape sequences includedHTTPie`s output.
You can create a shortcut for invoking HTTPie with colorized and paged outputby adding the following to your ~/.bash_profile
:
- function httpless {
- # `httpless example.org'
- http --pretty=all --print=hb "[email protected]" | less -R;
- }