← 返回命令列表

Linux command

xh 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Make GET request

xh [https://api.example.com/users]

Make POST with JSON data

xh POST [https://api.example.com/users] name=John email=john@example.com

Make POST with raw JSON

xh POST [https://api.example.com/users] < [data.json]

Set custom headers

xh [https://api.example.com] Authorization:"Bearer [token]"

Download file

xh --download [https://example.com/file.zip]

Show only response body

xh -b [https://api.example.com/users]

Show only headers

xh -h [https://api.example.com/users]

Follow redirects

xh --follow [https://example.com/redirect]

说明

xh is a friendly HTTP client, designed as a faster Rust reimplementation of HTTPie. It formats output with syntax highlighting and provides intuitive syntax for requests. Request items use special syntax: key=value for JSON/form data, key:=value for raw JSON values, key:value for headers. This enables building requests without complex quoting. Output is formatted and colored by default: JSON is pretty-printed, headers are highlighted. The -b flag outputs raw body for piping to other tools. Authentication supports basic, bearer token, and digest. Session support persists cookies and auth across requests. Download mode saves response bodies to files, with resume support for interrupted transfers. Progress is shown during download. The offline mode builds and displays requests without sending, useful for debugging or generating curl commands.

参数

(method)
HTTP method: GET, POST, PUT, PATCH, DELETE, HEAD.
-b, --body
Show only response body.
-h, --headers
Show only response headers.
-d, --download
Download file.
-c, --continue
Resume download.
-o _FILE_, --output _FILE_
Save response to file.
-f, --form
Send form data.
-j, --json
Send JSON data (default for POST).
-F, --follow
Follow redirects.
--offline
Build request without sending.
-p _WHAT_, --print _WHAT_
What to print: H(request headers), B(request body), h(response headers), b(response body).
-v, --verbose
Show request and response.
--timeout _SECS_
Request timeout.
-A _TYPE_, --auth-type _TYPE_
Auth type: basic, bearer, digest.
-a _USER:PASS_, --auth _USER:PASS_
Authentication credentials.
--proxy _PROTO:URL_
Proxy URL.
-I, --ignore-stdin
Ignore stdin data.

FAQ

What is the xh command used for?

xh is a friendly HTTP client, designed as a faster Rust reimplementation of HTTPie. It formats output with syntax highlighting and provides intuitive syntax for requests. Request items use special syntax: key=value for JSON/form data, key:=value for raw JSON values, key:value for headers. This enables building requests without complex quoting. Output is formatted and colored by default: JSON is pretty-printed, headers are highlighted. The -b flag outputs raw body for piping to other tools. Authentication supports basic, bearer token, and digest. Session support persists cookies and auth across requests. Download mode saves response bodies to files, with resume support for interrupted transfers. Progress is shown during download. The offline mode builds and displays requests without sending, useful for debugging or generating curl commands.

How do I run a basic xh example?

Run `xh [https://api.example.com/users]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does (method) do in xh?

HTTP method: GET, POST, PUT, PATCH, DELETE, HEAD.