xh
adalah alat yang ramah dan cepat untuk mengirim permintaan HTTP. Ini mengimplementasikan sebanyak mungkin desain HTTPIE yang sangat baik, dengan fokus pada peningkatan kinerja.
curl -sfL https://raw.githubusercontent.com/ducaale/xh/master/install.sh | sh
iwr -useb https://raw.githubusercontent.com/ducaale/xh/master/install.ps1 | iex
Os | Metode | Memerintah |
---|---|---|
Setiap | Muatan* | cargo install xh --locked |
Setiap | Huber | huber install xh |
Android (Termux) | pkg | pkg install xh |
Android (Magisk/Kernelsu) | Mmrl ** | mmrl install xhhttp |
Alpine Linux | APK *** | apk add xh |
Arch Linux | Pacman | pacman -S xh |
Debian & Ubuntu | Tepat**** | sudo apt install xh |
Freebsd | Freshports | pkg install xh |
Netbsd | PKGSRC | pkgin install xh |
Linux & MacOS | Nixpkgs | nix-env -iA nixpkgs.xh |
Linux & MacOS | Flox | flox install xh |
Linux & MacOS | Homebrew | brew install xh |
Linux & MacOS | Pertapa | hermit install xh |
MacOS | MacPorts | sudo port install xh |
Windows | Sendok | scoop install xh |
Windows | Cokelat | choco install xh |
Windows | Winget | winget add ducaale.xh |
* Pastikan Anda memiliki karat 1.74 atau yang lebih baru
** Anda harus menginstal MMRL CLI
*** Paket XH tersedia di tepi dan akan berada di v3.17+. Itu dibangun dengan TL Native saja.
**** Anda perlu menambahkan repositori yang tepat dari https://apt.cli.rs/
Halaman rilis berisi binari prebuilt untuk Linux, MacOS dan Windows.
Usage: xh [OPTIONS] <[METHOD] URL> [REQUEST_ITEM]... Arguments: <[METHOD] URL> The request URL, preceded by an optional HTTP method [REQUEST_ITEM]... Optional key-value pairs to be included in the request. Options: -j, --json (default) Serialize data items from the command line as a JSON object -f, --form Serialize data items from the command line as form fields --multipart Like --form, but force a multipart/form-data request even without files --raw <RAW> Pass raw request data without extra processing --pretty <STYLE> Controls output processing [possible values: all, colors, format, none] --format-options <FORMAT_OPTIONS> Set output formatting options -s, --style <THEME> Output coloring style [possible values: auto, solarized, monokai, fruity] --response-charset <ENCODING> Override the response encoding for terminal display purposes --response-mime <MIME_TYPE> Override the response mime type for coloring and formatting for the terminal -p, --print <FORMAT> String specifying what the output should contain -h, --headers Print only the response headers. Shortcut for --print=h -b, --body Print only the response body. Shortcut for --print=b -m, --meta Print only the response metadata. Shortcut for --print=m -v, --verbose... Print the whole request as well as the response --debug Print full error stack traces and debug log messages --all Show any intermediary requests/responses while following redirects with --follow -P, --history-print <FORMAT> The same as --print but applies only to intermediary requests/responses -q, --quiet... Do not print to stdout or stderr -S, --stream Always stream the response body -o, --output <FILE> Save output to FILE instead of stdout -d, --download Download the body to a file instead of printing it -c, --continue Resume an interrupted download. Requires --download and --output --session <FILE> Create, or reuse and update a session --session-read-only <FILE> Create or read a session without updating it form the request/response exchange -A, --auth-type <AUTH_TYPE> Specify the auth mechanism [possible values: basic, bearer, digest] -a, --auth <USER[:PASS] | TOKEN> Authenticate as USER with PASS (-A basic|digest) or with TOKEN (-A bearer) --ignore-netrc Do not use credentials from .netrc --offline Construct HTTP requests without sending them anywhere --check-status (default) Exit with an error status code if the server replies with an error -F, --follow Do follow redirects --max-redirects <NUM> Number of redirects to follow. Only respected if --follow is used --timeout <SEC> Connection timeout of the request --proxy <PROTOCOL:URL> Use a proxy for a protocol. For example: --proxy https:http://proxy.host:8080 --verify <VERIFY> If "no", skip SSL verification. If a file path, use it as a CA bundle --cert <FILE> Use a client side certificate for SSL --cert-key <FILE> A private key file to use with --cert --ssl <VERSION> Force a particular TLS version [possible values: auto, tls1, tls1.1, tls1.2, tls1.3] --https Make HTTPS requests if not specified in the URL --http-version <VERSION> HTTP version to use [possible values: 1.0, 1.1, 2, 2-prior-knowledge] --resolve <HOST:ADDRESS> Override DNS resolution for specific domain to a custom IP --interface <NAME> Bind to a network interface or local IP address -4, --ipv4 Resolve hostname to ipv4 addresses only -6, --ipv6 Resolve hostname to ipv6 addresses only -I, --ignore-stdin Do not attempt to read stdin --curl Print a translation to a curl command --curl-long Use the long versions of curl's flags --help Print help -V, --version Print version Each option can be reset with a --no-OPTION argument.
Jalankan xh help
untuk informasi yang lebih rinci.
xh
menggunakan sintaks permintaan-item HTTPIE untuk mengatur header, Badan Permintaan, String kueri, dll.
=
/ :=
Untuk mengatur bidang JSON atau bentuk badan permintaan ( =
untuk string dan :=
untuk tipe JSON lainnya).
==
Untuk menambahkan string kueri.
@
memasukkan file dalam permintaan multipart misalnya [email protected]
atau [email protected];type=image/jpeg;filename=goodbye.jpg
.
:
Untuk menambahkan atau menghapus header misalnya connection:keep-alive
atau connection:
.
;
untuk memasukkan header dengan nilai kosong misalnya header-without-value;
.
Prefix @
dapat digunakan untuk membaca nilai dari file. Misalnya: x-api-key:@api-key.txt
.
Badan permintaan juga dapat dibaca dari input standar, atau dari file menggunakan @filename
.
Untuk membuat objek JSON yang kompleks, jalur JSON dapat digunakan sebagai app[container][0][id]=090-5
. Untuk informasi lebih lanjut tentang sintaks ini, lihat https://httpie.io/docs/cli/nested-json.
Mirip dengan httpie, menentukan bagian skema dari URL permintaan adalah opsional, dan usus besar terkemuka berfungsi sebagai singkatan untuk LocalHost. :8000
setara dengan localhost:8000
, dan :/path
setara dengan localhost/path
.
URL dapat memiliki ://
yang memungkinkan dengan cepat mengubah URL menjadi perintah XH atau httpie yang valid. Misalnya http://httpbin.org/json
menjadi http ://httpbin.org/json
.
xh http: // localhost: 3000/user # diselesaikan ke http: // localhost: 3000/userxxh localhost: 3000/pengguna # diselesaikan ke http: // localhost: 3000/userxh: 3000/users # resolves ke http: // LocalHost: 3000/Usersxh:/Users # diselesaikan ke http: // localhost: 80/usersxh example.com # diselesaikan ke http: //example.comxh: //example.com # diselesaikan ke http://example.com
xh
akan default ke skema https jika nama biner adalah salah satu dari xhs
, https
, atau xhttps
. Jika Anda telah menginstal xh
melalui manajer paket, baik xh
dan xhs
harus tersedia secara default. Jika tidak, Anda perlu membuat yang seperti ini:
cd/path/to/xh && ln -s ./xh ./xhs xh httpbin.org/get # diselesaikan ke http://httpbin.org/getxhs httpbin.org/get # diselesaikan ke https://httpbin.org/get
Jika xh
dipanggil sebagai http
atau https
(dengan mengganti nama biner), atau jika variabel lingkungan XH_HTTPIE_COMPAT_MODE
diatur, itu akan berjalan dalam mode kompatibilitas httpie. Satu-satunya perbedaan saat ini adalah --check-status
tidak diaktifkan secara default.
# Kirim Get RequestXH httpbin.org/json# Kirim permintaan pos dengan body {"name": "Ahmed", "Age": 24} xh httpbin.org/post name = Ahmed Usia: = 24# Kirimkan permintaan dapatkan A GET a Get A Permintaan = dengan querystring id = 5 & sort = truexh dapatkan httpbin.org/json id == 5 sort == true# kirim permintaan get dan sertakan header bernama X-api-key dengan nilai 12345xh dapatkan httpbin.org/json x-api-key : 12345# Kirim permintaan pos dengan body bacaan dari stdin.echo "[1, 2, 3]" | XH POST httpbin.org/post# Kirim permintaan put dan pipa hasilnya ke lessxh put httpbin.org/put ID: = 49 Umur: = 25 | Less# unduh dan simpan ke res.jsonxh -d httpbin.org/json -o res.json# buat permintaan dengan pengguna kustom agen httpbin.org/get pengguna -agen: foobar
Kecepatan startup yang lebih baik.
Tersedia sebagai biner tunggal yang ditautkan secara statis yang mudah dipasang dan dibawa -bawa.
Dukungan HTTP/2.
Terjemahan Builtin ke Perintah Curl dengan -Bendera --curl
.
Output pendek, cheatsheet-style dari --help
. (Untuk output yang lebih lama, lulus help
.)
Tidak semua fitur httpie diimplementasikan. (#4)
Tidak ada sistem plugin.
Ketidakdewasaan umum. Httpie sudah tua dan teruji dengan baik.
Dokumentasi yang lebih buruk.
Curlie - Frontend to Curl yang menambahkan kemudahan penggunaan httpie
httpie-go-klien http seperti httpie ditulis di go
Curl2httpie - Konversi argumen perintah antara Curl dan httpie