oriolrius.cat

Des del 2000 compartiendo sobre…

Tag: httpie

HTTPie: The Next-Level Tool for Querying HTTP Resources

Reading time: 3 – 4 minutes

HTTPie is not only an intuitively designed tool, but it also offers user-friendly methods to send HTTP requests directly from the command line. For developers looking for a more elegant and visual approach than traditional tools like curl or wget, HTTPie comes as a refreshing solution.

Installing HTTPie Without System Packages

Sometimes, relying on system packages isn’t an option due to various constraints or the desire to always fetch the latest version directly. Here are three alternative methods to get the latest version of HTTPie:

Using curl with jq

curl -L -o http $(curl -s https://api.github.com/repos/httpie/cli/releases/latest | jq -r ".assets[] | select(.name == \"http\") | .browser_download_url")

Using wget with jq

wget -O http $(wget -q -O - https://api.github.com/repos/httpie/cli/releases/latest | jq -r ".assets[] | select(.name == \"http\") | .browser_download_url")

Python One-liner (Python 3)

python3 -c "from urllib.request import urlopen; from json import loads; open('http', 'wb').write(urlopen([asset['browser_download_url'] for asset in loads(urlopen('https://api.github.com/repos/httpie/cli/releases/latest').read().decode())['assets'] if asset['name'] == 'http'][0]).read())"

These methods ensure you’re directly fetching the binary from the latest GitHub release, bypassing any potential system package cache limitations.

Exploring HTTPie’s Features with Examples

To truly appreciate the capabilities of HTTPie, one should explore its rich array of features. The official HTTPie Examples page showcases a variety of use cases. From simple GET requests to more complex POST requests with data, headers, and authentication, the examples provided make it evident why HTTPie stands out.

For instance, performing a simple GET request is as easy as:

http https://httpie.io

Or, if you want to post data:

http POST httpie.io/post Hello=World

Dive deeper into the examples to discover how HTTPie can simplify your HTTP querying experience.

Conclusion

HTTPie offers a refreshing approach to HTTP interactions, bringing clarity and simplicity to the command line. With flexible installation methods and an array of powerful features, it’s an indispensable tool for developers aiming for efficiency. Give HTTPie a try, and it might just become your go-to for all HTTP-related tasks!

HTTPie – command line HTTP client

Reading time: 1 – 2 minutes

I imagine you are used to using curl for many command line scripts, tests, and much more things. I did the same but some weeks ago I discovered HTTPie which is the best substitute that I’ve ever found for curl. Of course, it’s also available for a lot of Linux distributions, Windows, and Mac. But I used it with docker which is much more transparent for the operative system and easy to update. To be more precise I use next alias trick for using this tool:

alias http='sudo docker run -it --rm --net=host clue/httpie'

Official website: httpie.org

Let me paste some highlights about HTTPie:

  • Sensible defaults
  • Expressive and intuitive command syntax
  • Colorized and formatted terminal output
  • Built-in JSON support
  • Persistent sessions
  • Forms and file uploads
  • HTTPS, proxies, and authentication support
  • Support for arbitrary request data and headers
  • Wget-like downloads
  • Extensions
  • Linux, macOS, and Windows support

From the tool webpage a nice comparison about how HTTPie looks like versus curl.