Httpie: A cURL alternative
github.com
github.com
$ time curl cs.marlboro.college
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://cs.marlboro.college /">here</a>.</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at cs.marlboro.college Port 80</address>
</body></html>
real 0m0.269s
user 0m0.004s
sys 0m0.005s
$ time http cs.marlboro.college
HTTP/1.1 301 Moved Permanently
Connection: Keep-Alive
Content-Length: 321
Content-Type: text/html; charset=iso-8859-1
Date: Sat, 27 Jan 2018 18:04:17 GMT
Keep-Alive: timeout=5, max=100
Location: https://cs.marlboro.college/
Server: Apache/2.4.18 (Ubuntu)
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://cs.marlboro.college/">here</a>.</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at cs.marlboro.college Port 80</address>
</body></html>
real 0m30.553s
user 0m0.437s
sys 0m0.052s[1] http://www.perlmonks.org/?node_id=168684
[2] http://www.editcorp.com/personal/lars_appel/wget/v1/wget_7.h...
The command line can be great for commanding, when it's done right, but it's not so great for most kinds of visualization, so CLI software that recognizes that and tries to compensate really helps.
$ http --print Hh http://news.ycombinator.comI’m not saying that this is a bad project. But “modern” doesn’t tell me anything about why I might want to use it.
- much more sane command line syntax
- automatic formatting and highlighting of json/xml/html
- automatically show received headers
- reverts to unproccessed output when redirected
PROTIP: use 'cat' to type the body manually:
cat | http post https://someapi.com/somenendpoint Authorization:sometoken
You can then start typing the message body.
When done, press ctrl+d (EOF) and the request will send and the reply will be printed.And if you already have the body in a separate file, just pipe it through:
cat mybody.json | http post https://someapi.com/somenendpoint Authorization:sometoken http post https://someapi.com/somenendpoint Authorization:sometoken < mybody.json<mybody.json http post https://someapi.com/somenendpoint Authorization:sometoken