jrv-http-client
A developer-friendly HTTP client for agents and scripts. Supports all HTTP methods, authentication, request bodies, pretty-printed responses, timing, and request history — all without needing curl flags memorized.
Quick Start
CODEBLOCK0
Commands
| Option | Description |
|---|
| INLINECODE0 | HTTP method |
| INLINECODE1 |
Target URL |
|
--json <body> | JSON request body (sets Content-Type: application/json) |
|
--form <data> | Form-encoded body (key=value&key2=val2) |
|
--bearer <token> | Bearer token Authorization header |
|
--auth <user:pass> | Basic auth |
|
--api-key <Header:value> | Custom API key header |
|
--header <H: V> | Add custom header (repeatable) |
|
--follow | Follow redirects (default: no) |
|
--timeout N | Request timeout in seconds (default: 30) |
|
--status-only | Print only the HTTP status code |
|
--output <file> | Save response body to file |
|
--output-json | Output full response as JSON (status, headers, body, timing) |
|
--timing | Show request/response timing |
|
--no-verify | Skip TLS certificate verification |
|
--verbose | Show request headers sent |
Response Format
By default, responses are pretty-printed:
- - JSON responses are syntax-highlighted and indented
- Other responses show raw text
- Status line and response headers are always shown
Exit Codes
- -
0 — HTTP 2xx response - INLINECODE17 — HTTP 4xx/5xx response
- INLINECODE18 — Network error, timeout, or usage error
Use Cases
- - API testing: Quick endpoint checks without Postman
- Health monitoring: Check if an API returns 200
- Auth testing: Test Bearer/Basic/API key auth flows
- Webhook debugging: Send test payloads to webhook endpoints
- CI scripts: Trigger API actions or check health in pipelines
jrv-http-client
一款面向开发者的 HTTP 客户端,适用于代理和脚本。支持所有 HTTP 方法、身份验证、请求体、格式化输出、计时和请求历史记录——无需记忆 curl 参数。
快速开始
bash
简单 GET 请求
python3 scripts/http_client.py GET https://httpbin.org/get
带 JSON 请求体的 POST
python3 scripts/http_client.py POST https://httpbin.org/post --json {name: test}
带表单数据的 POST
python3 scripts/http_client.py POST https://httpbin.org/post --form name=test&value=42
PUT 请求
python3 scripts/http_client.py PUT https://api.example.com/users/1 --json {role: admin}
DELETE 请求
python3 scripts/http_client.py DELETE https://api.example.com/users/1
Bearer 令牌认证
python3 scripts/http_client.py GET https://api.example.com/me --bearer mytoken123
基本认证
python3 scripts/http_client.py GET https://api.example.com/data --auth user:password
API 密钥请求头
python3 scripts/http_client.py GET https://api.example.com/data --api-key X-API-Key:abc123
自定义请求头
python3 scripts/http_client.py GET https://api.example.com/ --header Accept: application/json --header X-App: myapp
跟随重定向
python3 scripts/http_client.py GET https://example.com/ --follow
仅显示状态码
python3 scripts/http_client.py GET https://api.example.com/health --status-only
输出响应到文件
python3 scripts/http_client.py GET https://example.com/data.json --output response.json
超时设置
python3 scripts/http_client.py GET https://slow.api.example.com/ --timeout 10
显示请求计时
python3 scripts/http_client.py GET https://httpbin.org/get --timing
以 JSON 格式输出(适用于脚本)
python3 scripts/http_client.py GET https://httpbin.org/get --output-json
命令选项
| 选项 | 描述 |
|---|
| GET/POST/PUT/DELETE/PATCH/HEAD | HTTP 方法 |
| <url> |
目标 URL |
| --json | JSON 请求体(设置 Content-Type: application/json) |
| --form
| 表单编码的请求体(key=value&key2=val2) |
| --bearer | Bearer 令牌认证请求头 |
| --auth | 基本认证 |
| --api-key | 自定义 API 密钥请求头 |
| --header | 添加自定义请求头(可重复) |
| --follow | 跟随重定向(默认:否) |
| --timeout N | 请求超时秒数(默认:30) |
| --status-only | 仅打印 HTTP 状态码 |
| --output | 将响应体保存到文件 |
| --output-json | 以 JSON 格式输出完整响应(状态、请求头、响应体、计时) |
| --timing | 显示请求/响应计时 |
| --no-verify | 跳过 TLS 证书验证 |
| --verbose | 显示发送的请求头 |
响应格式
默认情况下,响应会进行格式化输出:
- - JSON 响应会进行语法高亮和缩进
- 其他响应显示原始文本
- 始终显示状态行和响应头
退出码
- - 0 — HTTP 2xx 响应
- 1 — HTTP 4xx/5xx 响应
- 2 — 网络错误、超时或使用错误
使用场景
- - API 测试:无需 Postman 即可快速检查端点
- 健康监控:检查 API 是否返回 200
- 认证测试:测试 Bearer/基本/API 密钥认证流程
- Webhook 调试:向 webhook 端点发送测试负载
- CI 脚本:触发 API 操作或在流水线中检查健康状态