Xh (replacement for postman, curl, httpie, etc.)

xh is worth checking out. It’s a rewrite of HTTPie in Rust, with a few extra features.

You can use it to learn curl by using the --curl flag like this:

xh post localhost:8000/articles/ title='my blog post' author='josh' --curl

It then prints out the curl version:

curl -X POST http://localhost:8000/articles/ -H 'content-type: application/json' -H 'accept: application/json, */*;q=0.5' -d '{"title":"my blog post","author":"josh"}'

The --offline flag shows what the request would look like (without sending it). This command:

xh post localhost:8000/articles/ title='my blog post' author='josh' --offline

prints out this data:

POST /articles/ HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 40
Content-Type: application/json
Host: localhost:8000
User-Agent: xh/0.15.0

{
    "title": "my blog post",
    "author": "josh"
}

Without those flags, it makes the actual request:

xh post localhost:8000/articles/ title='my blog post' author='josh'

which prints out the live response:

HTTP/1.1 201 Created
Content-Length: 52
Content-Type: application/json
Cross-Origin-Opener-Policy: same-origin
Date: Thu, 10 Mar 2022 03:34:50 GMT
Referrer-Policy: same-origin
Server: WSGIServer/0.2 CPython/3.10.2
X-Content-Type-Options: nosniff
X-Frame-Options: DENY

{
    "id": 9,
    "title": "my blog post",
    "author": "josh"
}

Here’s the Github page: