DEV Community

Cover image for HTTPie for Performance Engineers
NaveenKumar Namachivayam ⚡
NaveenKumar Namachivayam ⚡

Posted on • Originally published at qainsights.com

HTTPie for Performance Engineers

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

or

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.

HTTPie for Performance Engineers
HTTPie for Performance Engineers

Throughout this demo, we are going to use https variant.

HTTPie Features

  • 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
  • Plugins
  • Documentation
  • Test coverage

https://youtu.be/EBHqAPp1PIw

Usage

Hello World

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/get

HTTPie - Hello World

POST

https httpbin.org/post name=naveenkumar

Submit Form

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

Download File

https https://httpbin.org/image/png > myimage.png

Upload File

https POST https://httpbin.org/post < myimage.png

Follow Redirect

https --follow pie.dev/redirect/4

Proxy

https --proxy=http:http://localhost:3128 --proxy=https:https://localhost:1080 example.net

Skip HTTPS check

https --verify=no https://pie.dev/get

SSL Version

https --ssl=ssl3 https://example.org

View Headers

https httpbin.org/get -h

View Body

https httpbin.org/get -b

Stream

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.

Conclusion

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.

Discussion (0)