DEV Community

Cover image for What’s new in HTTPie 2.5.0
Mickaël Schoentgen for HTTPie

Posted on • Originally published at httpie.io

What’s new in HTTPie 2.5.0

We’re excited to introduce a new way of passing raw request data as an alternative to piping, XML pretty printing, and improved packaging.

Raw request data

HTTPie has always used piping as the way to pass raw request data:

# Standard way to pass raw request body:
$ echo 'Hello, World!' | http pie.dev/post
Enter fullscreen mode Exit fullscreen mode

Piping, even though elegant, isn’t always practical, however. When generating API docs examples, invoking HTTPie from a programming language, or writing a complex command on the terminal, it may be easier to use a CLI option instead. That has been an often requested feature.

In this release, we’ve added a new option called --raw, and HTTPie treats its value as if it came through STDIN. The following command does the same as the one above:

# New in HTTPie 2.5.0:
$ http --raw='Hello, World!' pie.dev/post
Enter fullscreen mode Exit fullscreen mode

Pretty printing of XML

JSON has been the lingua franca of the API world for a while, and HTTPie has always provided JSON formatting for terminal output. Many of our users work with XML as well, though, but XML bodies would be printed as they appear in the HTTP message, often on a single line:

<?xml version="1.0" encoding="utf-8"?><!-- comment --><root><element key='value'>text</element><element>text</element>tail<empty-element/></root>
Enter fullscreen mode Exit fullscreen mode

This release brings formatting to XML (and XHTML) messages as well:

<?xml version="1.0" encoding="utf-8"?>
<!-- comment -->
<root>
  <element key="value">text</element>
  <element>text</element>
  tail
  <empty-element/>
</root>
Enter fullscreen mode Exit fullscreen mode

You can control the formatting behaviour using the following format options:

  • Change the default 2-space indent size with --format-options=xml.indent:4.
  • Turn off XML formatting with --format-options=xml.format:false.

Packaging and distribution

Another theme for this release was improving HTTPie packaging and its availability for different platforms. The following channels have been (or are being) updated or newly added:

  • macOS: Homebrew, and MacPorts
  • Linux: Snap, Spack, Fedora, RedHat & CentOS via EPEL, Arch, Gentoo, Alpine, Manjaro, OpenSUSE, OpenPKG, and Solus
  • Windows: Chocolatey

We want to give a big shout-out to Miro Hrončok, the maintainer of the HTTPie package in Fedora, who has been especially involved and was of great help. And, of course, we are infinitely thankful to all the other package maintainers working behind the scenes.

Bug fixes

  • Resuming downloads (--download with --continue) with a single byte to be downloaded left is now fixed (#1032).
  • The behavior of --verbose requests with a streamed body when the server returned 307 Temporary Redirect is now fixed (#1088).
  • The handling of session files with Cookie: followed by other headers has been fixed (#1126).

Community contributions

We’d like to thank these amazing people for their contributions to this release: Miro Hrončok, Jan Verbeek, Almad, nixbytes, Marcel Stör, Jannik Vieten, Ilya Sukhanov, henryhu712, Elena Lape, Anton Emelyanov, a1346054, bl-ue.


Originally published on HTTPie blog.

Top comments (0)