2016-02-28 10:17:45 +00:00
|
|
|
# http
|
|
|
|
|
2024-08-25 20:51:01 +01:00
|
|
|
> HTTPie: an HTTP client designed for testing, debugging, and generally interacting with APIs & HTTP servers.
|
|
|
|
> More information: <https://httpie.io/docs/cli/usage>.
|
2016-02-28 10:17:45 +00:00
|
|
|
|
2024-08-25 20:51:01 +01:00
|
|
|
- Make a simple GET request (shows response header and content):
|
2016-02-28 10:17:45 +00:00
|
|
|
|
2024-08-25 20:51:01 +01:00
|
|
|
`http {{https://example.org}}`
|
2016-02-28 10:17:45 +00:00
|
|
|
|
2024-08-25 20:51:01 +01:00
|
|
|
- Print specific output content (`H`: request headers, `B`: request body, `h`: response headers, `b`: response body, `m`: response metadata):
|
2016-02-28 10:17:45 +00:00
|
|
|
|
2024-08-25 20:51:01 +01:00
|
|
|
`http --print {{H|B|h|b|m|Hh|Hhb|...}} {{https://example.com}}`
|
2016-02-28 10:17:45 +00:00
|
|
|
|
2024-08-31 19:40:15 +01:00
|
|
|
- Specify the HTTP method when sending a request and use a proxy to intercept the request:
|
2016-02-28 10:17:45 +00:00
|
|
|
|
2024-08-31 19:40:15 +01:00
|
|
|
`http {{GET|POST|HEAD|PUT|PATCH|DELETE|...}} --proxy {{http|https}}:{{http://localhost:8080|socks5://localhost:9050|...}} {{https://example.com}}`
|
2016-02-28 10:17:45 +00:00
|
|
|
|
2024-08-25 20:51:01 +01:00
|
|
|
- Follow any `3xx` redirects and specify additional headers in a request:
|
2016-02-28 10:17:45 +00:00
|
|
|
|
2024-09-03 01:43:42 +01:00
|
|
|
`http {{-F|--follow}} {{https://example.com}} {{'User-Agent: Mozilla/5.0' 'Accept-Encoding: gzip'}}`
|
2016-02-28 10:17:45 +00:00
|
|
|
|
2024-08-25 20:51:01 +01:00
|
|
|
- Authenticate to a server using different authentication methods:
|
2016-02-28 10:17:45 +00:00
|
|
|
|
2024-08-25 20:51:01 +01:00
|
|
|
`http --auth {{username:password|token}} --auth-type {{basic|digest|bearer}} {{GET|POST|...}} {{https://example.com/auth}}`
|
2016-02-28 10:17:45 +00:00
|
|
|
|
2024-08-25 20:51:01 +01:00
|
|
|
- Construct a request but do not send it (similar to a dry-run):
|
2016-02-28 10:17:45 +00:00
|
|
|
|
2024-08-25 20:51:01 +01:00
|
|
|
`http --offline {{GET|DELETE|...}} {{https://example.com}}`
|
2016-02-29 09:47:42 +00:00
|
|
|
|
2024-08-25 20:51:01 +01:00
|
|
|
- Use named sessions for persistent custom headers, auth credentials and cookies:
|
2016-02-29 09:47:42 +00:00
|
|
|
|
2024-08-25 20:51:01 +01:00
|
|
|
`http --session {{session_name|path/to/session.json}} {{--auth username:password https://example.com/auth API-KEY:xxx}}`
|
|
|
|
|
2024-09-12 07:12:02 +01:00
|
|
|
- Upload a file to a form (the example below assumes that the form field is `<input type="file" name="cv" />`):
|
2024-08-25 20:51:01 +01:00
|
|
|
|
|
|
|
`http --form {{POST}} {{https://example.com/upload}} {{cv@path/to/file}}`
|