The xh is a command line tool for sending HTTP requests. It replicates much of HTTPie outstanding design, prioritizing enhanced performance. This tutorial explains how to install xh HTTP requests sending tool on Ubuntu 24.04.
Install xh
Check the latest xh version available on its GitHub repository:
XH_VERSION=$(curl -s "https://api.github.com/repos/ducaale/xh/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+')
Download xh using the previously identified version:
wget -qO xh.tar.gz https://github.com/ducaale/xh/releases/latest/download/xh-v$XH_VERSION-x86_64-unknown-linux-musl.tar.gz
Create temporary directory and extract a tar.gz
file:
mkdir xh-temp
tar xf xh.tar.gz --strip-components=1 -C xh-temp
Move executable to /usr/local/bin
directory:
sudo mv xh-temp/xh /usr/local/bin
Use the following command to check the xh version:
xh --version
Remove the unnecessary archive and directory:
rm -rf xh.tar.gz xh-temp
Testing xh
The xh allows you to send HTTP requests using methods such as GET, POST, PUT, and others. For example, you can send a GET request by specifying the target URL as the first argument:
xh https://httpbin.org/get
Output example:
HTTP/2.0 200 OK
access-control-allow-credentials: true
access-control-allow-origin: *
content-length: 298
content-type: application/json
date: Tue, 16 Jul 2024 04:34:31 GMT
server: gunicorn/19.9.0
{
"args": {},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Host": "httpbin.org",
"User-Agent": "xh/0.22.2",
"X-Amzn-Trace-Id": "Root=1-6416c45e-47a4828a557d5fca764271d6"
},
"origin": "XXX.XXX.XXX.XXX",
"url": "https://httpbin.org/get"
}
Uninstall xh
To remove xh, delete the associated file:
sudo rm -rf /usr/local/bin/xh
Leave a Comment
Cancel reply