From 9817ecee4c10366c0b0b3bc6e0c234f1398cbc8f Mon Sep 17 00:00:00 2001 From: Fazle Arefin Date: Sat, 17 May 2025 13:06:07 +1000 Subject: [PATCH] xh: refresh page and add examples (#16504) --- pages/common/xh.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pages/common/xh.md b/pages/common/xh.md index 3cc59cb6d0..6811239487 100644 --- a/pages/common/xh.md +++ b/pages/common/xh.md @@ -5,26 +5,30 @@ > See also: `http`, `curl`. > More information: . -- Send a GET request: +- Send a GET request (shows response headers and content): -`xh {{httpbin.org/get}}` +`xh {{https://postman-echo.com/get}}` - 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}`): -`xh post {{httpbin.org/post}} {{name=john}} {{age:=25}}` +`xh post {{https://postman-echo.com/post}} {{name=john}} {{age=25}}` -- Send a GET request with query parameters (e.g. `first_param=5&second_param=true`): +- Send a GET request with query parameters (e.g. `https://postman-echo.com/response-headers?foo1=bar1&foo2=bar2`): -`xh get {{httpbin.org/get}} {{first_param==5}} {{second_param==true}}` +`xh get {{https://postman-echo.com/response-headers}} {{foo1==bar1}} {{foo2==bar2}}` - Send a GET request with a custom header: -`xh get {{httpbin.org/get}} {{header-name:header-value}}` +`xh get {{https://postman-echo.com}} {{header-name:header-value}}` - Make a GET request and save the response body to a file: -`xh --download {{httpbin.org/json}} --output {{path/to/file}}` +`xh {{[-d|--download]}} {{https://example.com}} {{[-o|--output]}} {{path/to/file}}` + +- Construct a request but do not send it (similar to a dry-run): + +`xh --offline {{get|delete|...}} {{https://example.com}}` - Show equivalent `curl` command (this will not send any request): -`xh --{{curl|curl-long}} {{--follow --verbose get http://example.com user-agent:curl}}` +`xh --{{curl|curl-long}} {{--follow --verbose get https://example.com user-agent:curl}}`