xh
é uma ferramenta amigável e rápida para enviar solicitações HTTP. Ele reimporta o máximo possível do excelente design da HTTPIE, com foco no desempenho melhorado.
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 | Método | Comando |
---|---|---|
Qualquer | Carga* | cargo install xh --locked |
Qualquer | 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 | APT **** | 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 | Eremita | hermit install xh |
macos | Macports | sudo port install xh |
Windows | Colher | scoop install xh |
Windows | Chocolatey | choco install xh |
Windows | Winget | winget add ducaale.xh |
* Certifique -se de ter ferrugem 1,74 ou posteriormente instalado
** Você precisará instalar a MMRL CLI
*** O pacote XH está disponível no Edge e estará na v3.17+. É construído apenas com TLS nativo.
**** você precisará adicionar o repositório APT em https://apt.cli.rs/
A página de liberação contém binários pré -construídos para Linux, MacOS e 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.
Execute xh help
para obter informações mais detalhadas.
xh
usa a sintaxe de solicitação-item do httpie para definir cabeçalhos, solicitar corpo, cordas de consulta, etc.
=
/ :=
Para definir os campos json ou formulário do corpo da solicitação ( =
para strings e :=
para outros tipos JSON).
==
para adicionar strings de consulta.
@
incluir arquivos em solicitações de multipart, por exemplo, [email protected]
ou [email protected];type=image/jpeg;filename=goodbye.jpg
.
:
Para adicionar ou remover cabeçalhos, por exemplo, connection:keep-alive
ou connection:
.
;
para incluir cabeçalhos com valores vazios, por exemplo header-without-value;
.
Um prefixo @
pode ser usado para ler um valor de um arquivo. Por exemplo: x-api-key:@api-key.txt
.
O corpo da solicitação também pode ser lido a partir da entrada padrão ou de um arquivo usando @filename
.
Para construir um objeto JSON complexo, um caminho JSON pode ser usado como um app[container][0][id]=090-5
. Para obter mais informações sobre esta sintaxe, consulte https://httpie.io/docs/cli/nested-json.
Semelhante ao httpie, especificar a parte do esquema do URL da solicitação é opcional, e um cólon líder trabalha como abreviação de localhost. :8000
é equivalente a localhost:8000
e :/path
é equivalente ao localhost/path
.
Os URLs podem ter um líder ://
que permite a conversão rapidamente de um URL em um comando válido XH ou HTTPIE. Por exemplo, http://httpbin.org/json
se torna http ://httpbin.org/json
.
xh http: // localhost: 3000/usuários # resolve http: // localhost: 3000/usersxh host: 3000/usuários # resolve http: // lochost: 3000/usuáriosxh: 3000/usuários # resolve http: // LocalHost: 3000/usuáriosxh:/usuários # resolve http: // localhost: 80/usersxh exemplo.com # resolve http: //example.comxh: //example.com # resolve http://example.com
xh
padrão é o esquema HTTPS se o nome binário for um dos xhs
, https
ou xhttps
. Se você instalou xh
por meio de um gerenciador de pacotes, xh
e xhs
devem estar disponíveis por padrão. Caso contrário, você precisa criar um assim:
CD/PATH/TO/XH && ln -s ./xh ./xhs xh httpbin.org/get # resolve http://httpbin.org/getxhs httpbin.org/get # resolve https://httpbin.org/get
Se xh
for invocado como http
ou https
(renomeando o binário), ou se a variável de ambiente XH_HTTPIE_COMPAT_MODE
for definida, ela será executada no modo de compatibilidade httpie. A única diferença atual é que --check-status
não está ativado por padrão.
# Envie um solicitação de solicitação httpbin.org/json# Envie uma solicitação de postagem com o corpo {"name": "Ahmed", "Age": 24} xh httpbin.org/Post Nome = Ahmed AGE: = 24# Envie uma solicitação GET GE com consulsão ids = 5 & sort = truexh obtenha httpbin.org/json id == 5 classy == true# Envie uma solicitação GET e inclua um cabeçalho chamado x-api-chave com valor 12345xh obter httpbin.org/json x-api-Key : 12345# Envie uma solicitação de postagem com a leitura corporal de stdin.echo "[1, 2, 3]" | xh post httpbin.org/post# Envie uma solicitação de put e tole o resultado para LessXH coloque httpbin.org/put ID: = 49 Idade: = 25 | menos# download e salve para res.jsonxh -d httpbin.org/json -o res.json# faça uma solicitação com um agente de usuário personalizado httpbin.org/get user-agent: foobar
Velocidade de inicialização aprimorada.
Disponível como um único binário estaticamente vinculado que é fácil de instalar e transportar.
Suporte HTTP/2.
Tradução incorporada para os comandos Curl com o sinalizador --curl
.
Saída curta e em estilo de trapaça de --help
. (Para uma saída mais longa, passe help
.)
Nem todos os recursos do HTTPIE são implementados. (#4)
Sem sistema de plug -in.
Imaturidade geral. Httpie é antigo e bem testado.
Pior documentação.
Curlie - Frontend para Curl que adiciona a facilidade de uso de httpie
httpie-go-cliente http do tipo httpie escrito em go
Curl2httpie - Converta argumentos de comando entre Curl e Httpie