# requests **Repository Path**: opsx-tools/requests ## Basic Information - **Project Name**: requests - **Description**: 高性能Web请求工具 - **Primary Language**: Go - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-13 - **Last Updated**: 2025-12-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # opsx-requests 高性能 HTTP 请求工具 ## 特性 - 🚀 **高性能**: 连接池复用、Keep-Alive、并发支持 - 🔄 **Session 支持**: 复用连接、cookies、headers - 🔐 **多种认证**: Basic、Bearer Token - 📤 **文件上传**: 支持 multipart/form-data - 📝 **表单数据**: 支持 application/x-www-form-urlencoded - 🎨 **自动 JSON**: 自动解析和格式化 JSON 响应 - 🌐 **代理支持**: HTTP/HTTPS 代理 - 🔒 **SSL 控制**: 可配置 SSL 证书验证 - 📊 **多种输出**: Pretty、JSON、Text 格式 ## 安装 ### 快速下载(推荐) 自动检测平台并下载最新版本: ```bash # 使用 wget wget "https://gitee.com/opsx-tools/requests/releases/download/latest/opsx-requests-$(uname -s)-$(uname -m).tar.gz" # 或使用 curl curl -L -o opsx-requests-$(uname -s)-$(uname -m).tar.gz \ "https://gitee.com/opsx-tools/requests/releases/download/latest/opsx-requests-$(uname -s)-$(uname -m).tar.gz" ``` ### 手动安装 ```bash # Linux/macOS tar -xzf opsx-requests-*.tar.gz chmod +x opsx-requests sudo mv opsx-requests /usr/local/bin/ # Windows # 解压 zip 文件后直接运行 ``` ## 编译 ```bash go build -o opsx-requests main.go ``` ## 快速开始 ### GET 请求 ```bash # 基本请求 opsx-requests get https://api.example.com/users # 带请求头和查询参数 opsx-requests get https://api.example.com/users \ -H "Authorization: Bearer token" \ -p "page=1" -p "limit=10" # JSON 输出格式 opsx-requests get https://api.example.com/users -o json ``` ### POST 请求 ```bash # JSON 数据 opsx-requests post https://api.example.com/users \ -d '{"name":"test","email":"test@example.com"}' # 表单数据 opsx-requests post https://api.example.com/users \ --form "name=test" --form "email=test@example.com" # 文件上传 opsx-requests post https://api.example.com/upload \ --files "file=/path/to/file.txt" ``` ### 认证 ```bash # Basic 认证 opsx-requests get https://api.example.com/users -a "basic:username:password" # Bearer Token opsx-requests get https://api.example.com/users -a "bearer:your-token-here" ``` ### 代理和 SSL ```bash # 使用代理 opsx-requests get https://api.example.com/users --proxy "http://127.0.0.1:8080" # 跳过 SSL 证书验证(仅用于测试) opsx-requests get https://api.example.com/users --insecure ``` ## 命令参数 ### 全局参数 - `-o, --output`: 输出格式 (pretty, json, text)(默认: "pretty") - `-s, --silent`: 静默模式,只输出响应体 - `-v, --verbose`: 详细模式,显示请求详情 - `--proxy`: 代理地址 - `--insecure`: 跳过 SSL 证书验证 ### 请求参数 - `-H, --header`: 自定义请求头(格式: Key:Value) - `-t, --timeout`: 请求超时时间(秒)(默认: 30) - `-a, --auth`: 认证信息(格式: basic:user:pass 或 bearer:token) - `-p, --params`: 查询参数(格式: key=value) - `-c, --content-type`: Content-Type ### POST/PUT/PATCH 参数 - `-d, --data`: 请求体数据 - `-f, --file`: 从文件读取请求体 - `--form`: 表单数据(格式: key=value,key2=value2) - `--form-data`: 表单数据(格式: key=value) - `--files`: 文件上传(格式: field=path) ## 许可证 MIT License - 详见 [LICENSE](LICENSE) 文件