Linux command
http 命令
网络
复制后可按需替换文件名、目录或参数。
常用示例
GET request
http [https://api.example.com/users]
POST with JSON
http POST [url] name=value
POST with form data
http --form POST [url] field=value
Custom headers
http [url] Authorization:"Bearer [token]"
Download file
http --download [url]
Authenticated request
http --auth [user]:[password] [url]
Verbose output
http --verbose [url]
Use a named session
http --session=[name] [url]
说明
HTTPie (http) is a user-friendly HTTP client. It provides intuitive syntax, colorized output, and JSON support for API interaction. The tool simplifies making HTTP requests from the command line. It automatically formats responses and supports sessions and authentication.
参数
- -d, --download
- Download file.
- -f, --form
- Form encoded data.
- -j, --json
- JSON data.
- -v, --verbose
- Verbose output.
- -o, --output _FILE_
- Output file.
- -a, --auth _USER:PASS_
- Basic or digest authentication credentials.
- -A, --auth-type _TYPE_
- Authentication type: basic, digest, bearer.
- --session _NAME_
- Create or reuse a named session for cookies and headers.
- -p, --print _FLAGS_
- Control output: H (request headers), B (request body), h (response headers), b (response body).
- --pretty _STYLE_
- Output formatting: all, colors, format, none.
- --verify _CERT_
- SSL certificate verification. Use no to skip.
- --proxy _PROTOCOL:URL_
- Use a proxy for requests.
- --follow
- Follow HTTP redirects.
- --help
- Display help information.
FAQ
What is the http command used for?
HTTPie (http) is a user-friendly HTTP client. It provides intuitive syntax, colorized output, and JSON support for API interaction. The tool simplifies making HTTP requests from the command line. It automatically formats responses and supports sessions and authentication.
How do I run a basic http example?
Run `http [https://api.example.com/users]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -d, --download do in http?
Download file.