A high-performance HTTP CLI tool with .http file support and syntax highlighting, built in Rust.
- High Performance: Built with Tokio async runtime and optimized for speed with LTO and mimalloc
- .http File Support: Parse and execute requests from .http files with variable substitution
- Syntax Highlighting: Beautiful colored output for JSON responses
- Download Mode: Stream large files to disk with progress bars and resume support
- Multipart Forms: Upload files and form data with automatic MIME type detection
- Multiple HTTP Methods: Support for GET, POST, PUT, DELETE, PATCH, HEAD, and OPTIONS
- Authentication: Basic auth, bearer tokens, and custom headers
- TLS/SSL: Full TLS support with custom CA certificates and client certificates
- HTTP/2: Support for both HTTP/1.1 and HTTP/2
- Compression: Automatic handling of gzip and brotli compression
- Benchmarking: Built-in performance testing capabilities
- Request Caching: Intelligent response caching
- Variable Substitution: Support for environment variables and custom variables in .http files
git clone https://github.com/adriannajera/httpcli
cd httpcli
cargo build --releaseThe binary will be available at target/release/httpcli.
- Rust 1.70 or higher
- OpenSSL development libraries (for TLS support)
# Simple GET request
httpcli GET https://api.example.com/users
# POST request with JSON data
httpcli POST https://api.example.com/users -d '{"name": "John Doe", "email": "john@example.com"}'
# Add custom headers
httpcli GET https://api.example.com/protected -H "Authorization: Bearer token123"
# PUT request with data
httpcli PUT https://api.example.com/users/1 -d '{"name": "Jane Doe"}'# GET request
httpcli get https://httpbin.org/ip
# POST request
httpcli post https://httpbin.org/post -d '{"test": "data"}'
# DELETE request
httpcli delete https://api.example.com/users/1Create a .http file with your requests:
@baseUrl = https://httpbin.org
@token = your_token_here
# @name Get IP
GET {{baseUrl}}/ip
###
# @name Post JSON Data
POST {{baseUrl}}/post
Content-Type: application/json
Authorization: Bearer {{token}}
{
"name": "Test User",
"email": "test@example.com",
"data": {
"key": "value",
"number": 42
}
}
###Execute the file:
httpcli --file requests.httpOr using the subcommand:
httpcli file requests.http# Basic authentication
httpcli GET https://api.example.com/protected -a username:password
# Bearer token
httpcli GET https://api.example.com/protected --token your_token_here
# Custom authorization header
httpcli GET https://api.example.com/protected -H "Authorization: Bearer token123"# Pretty formatted output (default)
httpcli GET https://api.example.com/users --output pretty
# JSON output only
httpcli GET https://api.example.com/users --output json
# Show headers only
httpcli GET https://api.example.com/users --output headers
# Raw body only
httpcli GET https://api.example.com/users --output body
# Verbose output
httpcli GET https://api.example.com/users --output verbose
# Show timing information
httpcli GET https://api.example.com/users --timing
# Show response headers
httpcli GET https://api.example.com/users --headers# Follow redirects
httpcli GET https://example.com/redirect --follow --max-redirects 5
# Set custom timeout
httpcli GET https://api.example.com/slow -t 60
# Custom User-Agent
httpcli GET https://api.example.com/users --user-agent "MyApp/1.0"
# Enable compression
httpcli GET https://api.example.com/large-data --compress
# Use proxy
httpcli GET https://api.example.com/users --proxy http://proxy.example.com:8080
# Save response to file
httpcli GET https://api.example.com/data --save response.json
# Read body from file
httpcli POST https://api.example.com/upload --data-binary file.json
# Disable TLS verification (insecure)
httpcli GET https://self-signed.example.com --insecureDownload large files with a progress indicator and optional resume support:
# Download a file with progress bar
httpcli get https://example.com/large-file.zip --download
# Download to a specific filename
httpcli get https://example.com/file.zip --download --output-file myfile.zip
# Resume a partial download (if server supports Range headers)
httpcli get https://example.com/large-file.zip --download --output-file myfile.zip --continue
# Download from GitHub releases (handles redirects automatically)
httpcli get https://github.com/user/repo/releases/download/v1.0/file.tar.gz --downloadThe download mode:
- Streams directly to disk (no memory buffering)
- Shows real-time progress bar with bytes transferred and ETA
- Automatically follows redirects (up to 10 by default)
- Automatically detects filename from URL if not specified
- Supports resuming interrupted downloads with
--continueflag - Handles servers that don't support resume gracefully
- Works with GitHub releases and CDN redirects
Upload files and form data using multipart/form-data encoding:
# Upload a file
httpcli post https://api.example.com/upload --form "file=@document.pdf"
# Send form fields
httpcli post https://api.example.com/submit --form "name=John" --form "email=john@example.com"
# Mix text fields and file uploads
httpcli post https://api.example.com/profile \\
--form "name=John Doe" \\
--form "avatar=@profile.jpg" \\
--form "resume=@resume.pdf"Form field syntax:
- Text field:
key=value - File upload:
key=@filepath(automatic MIME type detection)
# Custom CA certificate
httpcli GET https://api.example.com --cacert /path/to/ca.pem
# Client certificate authentication
httpcli GET https://api.example.com --cert /path/to/client.crt --key /path/to/client.key
# Specify HTTP version
httpcli GET https://api.example.com --http-version 2# Run 1000 requests with 50 concurrent connections
httpcli benchmark -n 1000 -c 50 https://api.example.com/health
# Run benchmark for 30 seconds
httpcli benchmark -d 30 -c 10 https://api.example.com/health# Use environment variables file
httpcli --env-file .env --file requests.http
# Pass variables via command line
httpcli --file requests.http --var baseUrl=https://api.example.com --var token=abc123
# Environment variables with HTTP_ prefix are automatically loaded
export HTTP_BASE_URL=https://api.example.com
httpcli --file requests.http# Initialize default configuration
httpcli config --init
# Show current configuration
httpcli config --show
# Use custom configuration file
httpcli --config /path/to/config.toml GET https://api.example.com# Enable/disable syntax highlighting
httpcli GET https://api.example.com/users --highlight true
# Choose color theme
httpcli GET https://api.example.com/users --theme base16-ocean.dark# Enable verbose logging
httpcli -v GET https://api.example.com/users
# Very verbose (multiple -v flags)
httpcli -vvv GET https://api.example.com/users
# Silent mode (only output response body)
httpcli -s GET https://api.example.com/users
# Set log level via environment variable
RUST_LOG=debug httpcli GET https://api.example.com/usersThe tool supports the standard .http file format used by popular HTTP clients:
- Variables: Define with
@variableName = value - Variable References: Use with
{{variableName}} - Request Names: Comment with
# @name RequestName - Request Separator: Use
###to separate multiple requests - Headers: One per line after the request line
- Body: Add after a blank line following headers
Example:
@host = api.example.com
@apiKey = your-api-key
# @name List Users
GET https://{{host}}/users
Authorization: Bearer {{apiKey}}
###
# @name Create User
POST https://{{host}}/users
Content-Type: application/json
Authorization: Bearer {{apiKey}}
{
"name": "John Doe",
"email": "john@example.com"
}
###The project is structured into several modules:
- cli: Command-line argument parsing and interface
- client: HTTP client implementation with connection pooling
- http_parser: Parser for .http files using nom combinators
- request: HTTP request building and formatting
- response: HTTP response handling and formatting
- syntax: Syntax highlighting for JSON and other formats
- tls: TLS/SSL certificate handling
- cache: Response caching implementation
- config: Configuration file management
- error: Error types and handling
- mimalloc: Fast memory allocator for improved performance
- LTO: Link-time optimization enabled in release builds
- HTTP/2: Support for multiplexing and header compression
- Connection Pooling: Reuse connections for better performance
- Async I/O: Built on Tokio for efficient concurrency
- Smart Caching: Cache responses to reduce redundant requests
MIT OR Apache-2.0