Skip to content

ducaale/xh

xhxh  是一个友好且快速的发送 HTTP 请求的工具,旨在为 curl 提供一个友好的界面。它尽可能地重新实现了 HTTPie 的优秀设计,重点是提高性能。

xh  相比 httpie 来说,主要是提高了性能、可作为单个静态链接的二进制文件,易于安装、支持 HTTP / 2、使用 curl 标志内置对 curl 命令的转换、简短的帮助信息可通过备忘单样式进行输出。

安装:

bash
sudo pacman -S xh

scoop install xh
bash
# xh 的语法
xh [OPTIONS] <[METHOD] URL> [--] [REQUEST_ITEM]...

# 发送 GET 请求
xh httpbin.org/json

# 发送一个 POST 请求,请求体{"name": "ahmed", "age": 24}
xh httpbin.org/post name=ahmed age:=24

# 发送一个 querystring id=5 & sort=true 的 GET 请求
xh get httpbin.org/json id==5 sort==true

# 发送一个 GET 请求,并包含一个名为 x-api-key 的头,值为:66666
xh get httpbin.org/json x-api-key:66666

# 发送一个 PUT 请求,并将结果管道到 less
xh put httpbin.org/put id:=49 age:=24 | less

# 下载并保存到 test.json
xh -d httpbin.org/json -o test.json

# 请求与自定义用户代理
xh httpbin.org/get user-agent:foobar