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:

  1. $ http example.org/Movie.mov > Movie.mov

Download an image of Octocat, resize it using ImageMagick, upload it elsewhere:

  1. $ 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:

  1. $ 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:

  1. function httpless {
  2. # `httpless example.org'
  3. http --pretty=all --print=hb "[email protected]" | less -R;
  4. }