Files
tldr/pages.zh/common/xh.md

30 lines
985 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# xh
> 友好且快速的HTTP请求发送工具。
> 注意:`xh` 是用Rust编写的有效地替代了 `http`。
> 另请参阅:`http``curl`。
> 更多信息:<https://github.com/ducaale/xh>。
- 发送GET请求
`xh {{httpbin.org/get}}`
- 发送带有JSON主体的POST请求键值对将添加到顶级JSON对象中 - 例如 `{"name": "john", "age": 25}`
`xh post {{httpbin.org/post}} {{name=john}} {{age:=25}}`
- 发送带有查询参数的GET请求例如 `first_param=5&second_param=true`
`xh get {{httpbin.org/get}} {{first_param==5}} {{second_param==true}}`
- 发送带有自定义头部的GET请求
`xh get {{httpbin.org/get}} {{header-name:header-value}}`
- 发起GET请求并将响应主体保存到文件中
`xh --download {{httpbin.org/json}} --output {{path/to/file}}`
- 显示等效的 `curl` 命令(这不会发送任何请求):
`xh --{{curl|curl-long}} {{--follow --verbose get http://example.com user-agent:curl}}`