HTTPie is a great command line tool for working with HTTP-based APIs. If you're just getting started, check out the earlier post I wrote on Setting Up HTTPie for Akamai.
HTTP/2 (h2) is the new version of the HTTP Protocol, and in this follow-up I explain how to enable HTTP/2 support for HTTPie.
Enabling HTTP/2 Support for HTTPie
First you need to see if your HTTPie client has HTTP/2 support already. You can do this from a terminal window.
Open a Terminal window and type the command below:
$ http -h https://h2book.com HTTP/1.1 200 OK ...
Look for the HTTP protocol version before the "200 OK" response. If you see "HTTP/1.1" then you need to follow the instructions below to enable support for HTTP/2).
Install HTTP/2 support on HTTPie
To install the HTTP/2 plugin for HTTPie, open a Terminal window and type the command below:
$ pip install -U httpie httpie-http2 Requirement already up-to-date: httpie in /usr/local/lib/python2.7/site-packages Collecting httpie-http2 Downloading httpie-http2-0.0.1.tar.gz Requirement already up-to-date: Pygments>=2.1.3 in /usr/local/lib/python2.7/site-packages ... Requirement already up-to-date: requests>=2.11.0 in /usr/local/lib/python2.7/site-packages ... Collecting hyper (from httpie-http2) Downloading hyper-0.7.0-py2.py3-none-any.whl (269kB) 100% |████████████████████████████████| 276kB 2.3MB/s Collecting hyperframe<4.0,>=3.2 (from hyper->httpie-http2) Downloading hyperframe-3.2.0-py2.py3-none-any.whl Collecting h2<3.0,>=2.4 (from hyper->httpie-http2) Downloading h2-2.6.2-py2.py3-none-any.whl (71kB) 100% |████████████████████████████████| 81kB 4.7MB/s Requirement already up-to-date: enum34<2,>=1.0.4; python_version == "2.7" or python_version ... Collecting hpack<4,>=2.2 (from h2<3.0,>=2.4->hyper->httpie-http2) Downloading hpack-3.0.0-py2.py3-none-any.whl Building wheels for collected packages: httpie-http2 Running setup.py bdist_wheel for httpie-http2 ... done Stored in directory: /Users/jgarza/Library/Caches/pip/wheels/68/a3/c0/1266ef4095eba35673a ... Successfully built httpie-http2 Installing collected packages: hyperframe, hpack, h2, hyper, httpie-http2 Successfully installed h2-2.6.2 hpack-3.0.0 httpie-http2-0.0.1 hyper-0.7.0 hyperframe-3.2.0
Verify HTTP/2 support on HTTPie
Now repeat the same request we did earlier and confirm you see "HTTP/2" in the protocol version.
$ http -h https://h2book.com HTTP/2 200 ...
That's all there is to it, have fun with HTTP/2!
To learn more about HTTP/2, see the O'Reilly book Learning HTTP/2.