In this blog post we are going to learn HTTPie - a command line utility to debug web services. In our last post, we read about cURL for Performance Engineers. If you are looking for a cURL alternative, you can check out HTTPie.
What is HTTPie?
Here is the excerpt from httpie.io:
HTTPie (pronounced aitch-tee-tee-pie) is a command-line HTTP client. Its goal is to make CLI interaction with web services as human-friendly as possible. HTTPie is designed for testing, debugging, and generally interacting with APIs & HTTP servers.
It supports both http and https; displays it in color by default.
How to install HTTPIe?
You can HTTPie on Linux, Windows and macOS. The only prerequisite is Python 3.6 or greater.
Head to https://httpie.io/docs#installation to see the instructions based on your OS.
In this demonstration, we are going to utilize HTTPie on Windows Subsystem for Linux (WSL).
Issue any one of the below command to install HTTPie.
sudo apt install httpie
python -m pip install --upgrade pip setuptools python -m pip install --upgrade httpie
After successful installation, you can validate by issuing
http --version or
https --version which will display the installed version of httpie.
Throughout this demo, we are going to use
- Expressive and intuitive syntax
- Formatted and colorized terminal output
- Built-in JSON support
- Forms and file uploads
- HTTPS, proxies, and authentication.
- Arbitrary request data
- Custom headers
- Persistent sessions
- Wget-like downloads
- Linux, macOS and Windows support
- Test coverage
Let us start with the simple
GET method using the httpbin.org demo app. As you can see, by default, httpie will display the response and the headers in the colored format.
https httpbin.org/post name=naveenkumar
https -f httpbin.org/post custname=naveenkumar&custtel=&custemail=&size=small&topping=mushroom&delivery=&comments=
View the sent request
https -v httpbin.org/post name=naveenkumar
https https://httpbin.org/image/png > myimage.png
https POST https://httpbin.org/post < myimage.png
https --follow pie.dev/redirect/4
https --proxy=http:http://localhost:3128 --proxy=https:https://localhost:1080 example.net
Skip HTTPS check
https --verify=no https://pie.dev/get
https --ssl=ssl3 https://example.org
https httpbin.org/get -h
https httpbin.org/get -b
http --stream httpbin.org/stream/3
I have listed only the frequently commands which I use for debugging. Apart from these, HTTPie supports named sessions, wget-like downloads, piping, formatting, resuming downloads, conditional body download, SOCKS, and more.
Here is the GitHub repo for your reference: https://github.com/httpie/httpie
HTTPie will be available for the web and desktop soon.
If you are looking to debug HTTP requests and for cURL alternative, then HTTPie is for you. Easy to learn and get started; comes with powerful features and format options.
Oldest comments (0)