xh
es una herramienta amigable y rápida para enviar solicitudes HTTP. Reimplace tanto como sea posible del excelente diseño de Httpie, con un enfoque en un rendimiento mejorado.
curl -sfL https://raw.githubusercontent.com/ducaale/xh/master/install.sh | sh
iwr -useb https://raw.githubusercontent.com/ducaale/xh/master/install.ps1 | iex
Sistema operativo | Método | Dominio |
---|---|---|
Cualquier | Carga* | cargo install xh --locked |
Cualquier | 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 y Ubuntu | Apto**** | sudo apt install xh |
FreeBSD | Freshports | pkg install xh |
Netbsd | pkgsrc | pkgin install xh |
Linux y macOS | Nixpkgs | nix-env -iA nixpkgs.xh |
Linux y macOS | Flox | flox install xh |
Linux y macOS | Cerveza casera | brew install xh |
Linux y macOS | Ermitaño | hermit install xh |
macosa | MacPorts | sudo port install xh |
Windows | Cuchara | scoop install xh |
Windows | Chocolate | choco install xh |
Windows | Alero | winget add ducaale.xh |
* Asegúrese de tener Rust 1.74 o más tarde instalado
** Tendrá que instalar la CLI MMRL
*** El paquete XH está disponible en el borde y estará en V3.17+. Está construido solo con TLS nativo.
**** Deberá agregar el repositorio de apt desde https://apt.cli.rs/
La página de lanzamiento contiene binarios previos a la construcción de Linux, macOS y 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.
Ejecute xh help
para obtener información más detallada.
xh
usa la sintaxis de solicitud de pedido de httpie para establecer encabezados, cuerpo de solicitud, cadena de consulta, etc.
=
/ :=
para configurar los campos JSON o formulario del cuerpo de solicitud ( =
para cadenas y :=
para otros tipos JSON).
==
para agregar cadenas de consulta.
@
incluir archivos en solicitudes multipart, por ejemplo, [email protected]
o [email protected];type=image/jpeg;filename=goodbye.jpg
.
:
para agregar o eliminar encabezados, por ejemplo, connection:keep-alive
o connection:
.
;
para incluir encabezados con valores vacíos, por ejemplo header-without-value;
.
Se puede usar un @
prefix para leer un valor de un archivo. Por ejemplo: x-api-key:@api-key.txt
.
El cuerpo de solicitud también se puede leer desde la entrada estándar, o desde un archivo usando @filename
.
Para construir un objeto JSON complejo, una ruta JSON se puede usar como una app[container][0][id]=090-5
. Para obtener más información sobre esta sintaxis, consulte https://httpie.io/docs/cli/nested-json.
Similar a HTTPIE, especificar la parte del esquema de la URL de solicitud es opcional, y un colon líder funciona como taquigrafía para localhost. :8000
es equivalente a localhost:8000
, y :/path
es equivalente a localhost/path
.
Las URL pueden tener un liderazgo ://
que permite convertir rápidamente una URL en un comando XH o HTTPIE válido. Por ejemplo, http://httpbin.org/json
se convierte en http ://httpbin.org/json
.
xh http: // localhost: 3000/usuarios # se resuelve a http: // localhost: 3000/usersxh localhost: 3000/users # se resuelve para http: // localhost: 3000/userssxh: 3000/usser # # se resuelve a http: // Localhost: 3000/UsersXH:/Users # se resuelve a http: // localhost: 80/usersxh Ejemplo.com # se resuelve a http: //example.comxh: //example.com # se resuelve a http://example.com
xh
se predeterminará al esquema HTTPS si el nombre binario es uno de xhs
, https
o xhttps
. Si ha instalado xh
a través de un Administrador de paquetes, tanto xh
como xhs
deberían estar disponibles de forma predeterminada. De lo contrario, debe crear uno como este:
CD/PATH/TO/XH && ln -s ./xh ./xhs xh httpbin.org/get # se resuelve a http://httpbin.org/getxhs httpbin.org/get # se resuelve a https://httpbin.org/get
Si se invoca xh
como http
o https
(al cambiar el nombre del binario), o si se establece la variable de entorno XH_HTTPIE_COMPAT_MODE
, se ejecutará en el modo de compatibilidad HTTPIE. La única diferencia actual es que: --check-status
no está habilitado de forma predeterminada.
# Enviar un requestxh httpbin.org/json# Enviar una solicitud de publicación con el cuerpo {"nombre": "ahmed", "edad": 24} xh httpbin.org/post name = ahmed edad: = 24# enviar una solicitud get a get con QueryString id = 5 & sorty = trueXh get httpbin.org/json id == 5 sort == True# Enviar una solicitud Get e incluya un encabezado llamado X-API-Key con valor 12345XH get httpbin.org/json x-api-key key : 12345# Enviar una solicitud de publicación con el cuerpo leído desde stdin.echo "[1, 2, 3]" | xh post httpbin.org/post# Envíe una solicitud de put y tuve el resultado a menosxh poner httpbin.org/put id: = 49 edad: = 25 | Menos# descargar y guardar en res.jsonxh -d httpbin.org/json -o res.json# hacer una solicitud con un usuario personalizado agentexh httpbin.org/get user-agent: foobar
Velocidad de inicio mejorada.
Disponible como un solo binario estáticamente vinculado que es fácil de instalar y llevar.
Soporte HTTP/2.
Traducción construida a comandos curl con el indicador --curl
.
Breve, salida de estilo de hoja de trucos de --help
. (Para una salida más larga, pase help
).
No se implementan todas las características de HTTPIE. (#4)
Sin sistema de complementos.
Inmaturidad general. Httpie es viejo y bien probado.
Peor documentación.
CURLIE - Frontend to rizo que agrega la facilidad de uso de httpie
httpie-go-cliente HTTP tipo httpie escrito en Go
curl2httpie - Convertir argumentos de comando entre curl y httpie