mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-09-10 16:53:10 +02:00
http: edit page (#13507)
This commit is contained in:
parent
93d24e1f0e
commit
757a356a7f
1 changed files with 20 additions and 16 deletions
|
@ -1,32 +1,36 @@
|
|||
# http
|
||||
|
||||
> HTTPie: HTTP client, aims to be easier to use than cURL.
|
||||
> More information: <https://httpie.org>.
|
||||
> HTTPie: an HTTP client designed for testing, debugging, and generally interacting with APIs & HTTP servers.
|
||||
> More information: <https://httpie.io/docs/cli/usage>.
|
||||
|
||||
- Download a URL to a file:
|
||||
- Make a simple GET request (shows response header and content):
|
||||
|
||||
`http --download {{example.org}}`
|
||||
`http {{https://example.org}}`
|
||||
|
||||
- Send form-encoded data:
|
||||
- Print specific output content (`H`: request headers, `B`: request body, `h`: response headers, `b`: response body, `m`: response metadata):
|
||||
|
||||
`http --form {{example.org}} {{name='bob'}} {{profile_picture@'bob.png'}}`
|
||||
`http --print {{H|B|h|b|m|Hh|Hhb|...}} {{https://example.com}}`
|
||||
|
||||
- Send JSON object:
|
||||
- Specify the HTTP method when sending a request:
|
||||
|
||||
`http {{example.org}} {{name='bob'}}`
|
||||
`http {{GET|POST|HEAD|PUT|PATCH|DELETE|...}} {{https://example.com}}`
|
||||
|
||||
- Specify an HTTP method:
|
||||
- Follow any `3xx` redirects and specify additional headers in a request:
|
||||
|
||||
`http {{HEAD}} {{example.org}}`
|
||||
`http {{--follow|-F}} {{https://example.com}} {{'User-Agent: Mozilla/5.0' 'Accept-Encoding: gzip'}}`
|
||||
|
||||
- Include an extra header:
|
||||
- Authenticate to a server using different authentication methods:
|
||||
|
||||
`http {{example.org}} {{X-MyHeader:123}}`
|
||||
`http --auth {{username:password|token}} --auth-type {{basic|digest|bearer}} {{GET|POST|...}} {{https://example.com/auth}}`
|
||||
|
||||
- Pass a username and password for server authentication:
|
||||
- Construct a request but do not send it (similar to a dry-run):
|
||||
|
||||
`http --auth {{username:password}} {{example.org}}`
|
||||
`http --offline {{GET|DELETE|...}} {{https://example.com}}`
|
||||
|
||||
- Specify raw request body via `stdin`:
|
||||
- Use named sessions for persistent custom headers, auth credentials and cookies:
|
||||
|
||||
`cat {{data.txt}} | http PUT {{example.org}}`
|
||||
`http --session {{session_name|path/to/session.json}} {{--auth username:password https://example.com/auth API-KEY:xxx}}`
|
||||
|
||||
- Upload a file to a form (the example below assumes form field is `<input type="file" name="cv" />`):
|
||||
|
||||
`http --form {{POST}} {{https://example.com/upload}} {{cv@path/to/file}}`
|
||||
|
|
Loading…
Add table
Reference in a new issue