1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-29 23:24:55 +02:00
tldr/pages/common/xh.md

31 lines
1,007 B
Markdown
Raw Normal View History

2021-04-05 15:01:13 +02:00
# xh
> Friendly and fast tool for sending HTTP requests.
2024-09-13 17:34:08 +10:00
> Note: `xh`, written in rust, serves as an effective drop-in replacement for `http`.
> See also: `http`, `curl`.
2021-04-05 15:01:13 +02:00
> More information: <https://github.com/ducaale/xh>.
2021-04-05 15:11:13 +02:00
- Send a GET request:
2021-04-05 15:01:13 +02:00
2021-04-05 15:08:16 +02:00
`xh {{httpbin.org/get}}`
2021-04-05 15:01:13 +02:00
- Send a POST request with a JSON body (key-value pairs are added to a top-level JSON object - e.g. `{"name": "john", "age": 25}`):
2021-04-05 15:01:13 +02:00
2021-04-05 15:08:16 +02:00
`xh post {{httpbin.org/post}} {{name=john}} {{age:=25}}`
2021-04-05 15:01:13 +02:00
2021-04-11 16:43:44 +02:00
- Send a GET request with query parameters (e.g. `first_param=5&second_param=true`):
2021-04-05 15:01:13 +02:00
2021-04-11 16:43:44 +02:00
`xh get {{httpbin.org/get}} {{first_param==5}} {{second_param==true}}`
2021-04-05 15:01:13 +02:00
- Send a GET request with a custom header:
2021-04-05 15:01:13 +02:00
`xh get {{httpbin.org/get}} {{header-name:header-value}}`
2021-04-05 15:01:13 +02:00
- Make a GET request and save the response body to a file:
2021-04-05 15:01:13 +02:00
`xh --download {{httpbin.org/json}} --output {{path/to/file}}`
2024-09-13 17:34:08 +10:00
- Show equivalent `curl` command (this will not send any request):
`xh --{{curl|curl-long}} {{--follow --verbose get http://example.com user-agent:curl}}`