xh
ist ein freundliches und schnelles Werkzeug zum Senden von HTTP -Anfragen. Es wird so weit wie möglich von HTTPIEs hervorragendem Design durchgeführt und konzentriert sich auf eine verbesserte Leistung.
curl -sfL https://raw.githubusercontent.com/ducaale/xh/master/install.sh | sh
iwr -useb https://raw.githubusercontent.com/ducaale/xh/master/install.ps1 | iex
Betriebssystem | Verfahren | Befehl |
---|---|---|
Beliebig | Ladung* | cargo install xh --locked |
Beliebig | 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 | Geeignet**** | 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 | Einsiedler | hermit install xh |
macos | Macports | sudo port install xh |
Fenster | Scoop | scoop install xh |
Fenster | Schokoladig | choco install xh |
Fenster | Winget | winget add ducaale.xh |
* Stellen Sie sicher, dass Sie Rost 1.74 oder später installiert haben
** Sie müssen die MMRL CLI installieren
*** Das XH -Paket ist in Kante erhältlich und wird in v3.17+sein. Es ist nur mit nativen TLS gebaut.
**** Sie müssen das APT -Repository von https://apt.cli.rs/ hinzufügen
Die Release -Seite enthält vorgefertigte Binärdateien für Linux, MacOS und 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.
Führen Sie xh help
für detailliertere Informationen aus.
xh
verwendet die Request-Item-Syntax von Httpie, um Header, Anforderungsorganisation, Abfrage-Zeichenfolge usw. festzulegen.
=
/ :=
zum Festlegen der JSON- oder Formularfelder des Anforderungskörpers ( =
für Zeichenfolgen und :=
für andere JSON -Typen).
==
zum Hinzufügen von Abfragesteichen.
@
für die Aufnahme von Dateien in Multipart -Anfragen z. B. [email protected]
oder [email protected];type=image/jpeg;filename=goodbye.jpg
.
:
Zum Hinzufügen oder Entfernen von Header zB connection:keep-alive
oder connection:
.
;
für die Einbeziehung von Headern mit leeren Werten z. B. header-without-value;
.
Mit einem @
-Präfix kann ein Wert aus einer Datei gelesen werden. Zum Beispiel: x-api-key:@api-key.txt
.
Das Anforderungsgremium kann auch aus Standardeingaben oder aus einer Datei mit @filename
gelesen werden.
Um ein komplexes JSON-Objekt zu erstellen, kann ein JSON-Pfad als Schlüssel-EG app[container][0][id]=090-5
verwendet werden. Weitere Informationen zu dieser Syntax finden Sie unter https://httpie.io/docs/cli/nested-json.
Ähnlich wie bei HTTPIE ist es optional, den Schema -Teil der Anfrage -URL anzugeben, und ein führender Dickdarm arbeitet als Kurzform für Localhost. :8000
entspricht localhost:8000
, und :/path
entspricht localhost/path
.
URLs können eine führende ://
haben, mit der eine URL schnell in einen gültigen XH- oder HTTPIE -Befehl konvertiert werden kann. Zum Beispiel wird http://httpbin.org/json
http ://httpbin.org/json
.
xh http: // localhost: 3000/user # entschlossen zu http: // localhost: 3000/userXH localhost: 3000/user # entschlossen zu http: // localhost: 3000/userXH: 3000/user # Auflösungen zu http: // localhost: 3000/userXH:/user # entschlossen zu http: // localhost: 80/userXH example.com
xh
wird standardmäßig mit dem HTTPS -Schema eingestellt, wenn der binäre Name einer von xhs
, https
oder xhttps
ist. Wenn Sie xh
über einen Paketmanager installiert haben, sollten sowohl xh
als auch xhs
standardmäßig verfügbar sein. Andernfalls müssen Sie eine solche erstellen:
cd/path/to/xh && ln -s ./xh ./xhs xh httpbin.org/get # entschlossen zu http://httpbin.org/getxhs httpbin.org/get # Auflösungen zu https://httpbin.org/get
Wenn xh
als http
oder https
(durch Umbenennen des Binary) aufgerufen wird oder wenn die Umgebungsvariable XH_HTTPIE_COMPAT_MODE
festgelegt ist, wird er im Kompatibilitätsmodus des HTTPie -Kompatibilitätsmodus ausgeführt. Der einzige aktuelle Unterschied besteht darin, dass --check-status
standardmäßig nicht aktiviert ist.
# Senden Sie eine Get RequestXH httpbin.org/json# eine Postanforderung mit Body {"Name": "Ahmed", "Alter": 24} xh httpbin.org/post name = Ahmed Alter: = 24# eine Get -Anfrage senden mit queryString id = 5 & sort = truexh erhalten : 12345# Senden Sie eine Postanforderung mit LEAD VON STDIN.ECHO "[1, 2, 3]" | xh post httpbin.org/post# Senden Sie eine Put -Anforderung und leiten Sie das Ergebnis an Lessxh Put httpbin.org/put ID: = 49 Alter: = 25 | Weniger# Download und Speichern auf res.jsonxh -d httpbin.org/json -o res.json# stellen
Verbesserte Startgeschwindigkeit.
Erhältlich als einzelner statisch verknüpfter binär, das einfach zu installieren und zu tragen ist.
HTTP/2 -Unterstützung.
Ingebaute Übersetzung zu Curl -Befehlen mit der --curl
.
Kurze Ausgabe im Cheatsheet-Stil von --help
. (Für längere Ausgabe, help
.)
Nicht alle Funktionen von HTTPIE werden implementiert. (#4)
Kein Plugin -System.
Allgemeine Unreife. Httpie ist alt und gut getestet.
Schlimmere Dokumentation.
Curlie - Frontend to Curl, der die Benutzerfreundlichkeit von Httpie ergänzt
httpie-go-httpie-ähnlicher HTTP-Client in Go geschrieben
curl2httpie - Befehlsargumente zwischen curl und httpie konvertieren