HTTPCan
A simple, high‑performance HTTP request & response service built with Rust and Actix Web. Fully compatible with httpbin.org, with modern streaming and AI‑friendly enhancements.
Quick Links: Quick Start · Installation · Configuration · Examples · OpenAPI & Web UI · API Reference · Library · Development · License
✨ Features
- HTTPBin compatible: Use as a drop‑in replacement for testing/migration
- Modern streaming: Native SSE and NDJSON, AI‑compatible formats (OpenAI/Ollama)
- Tiny Docker image: <10MB, fast to pull and start
- Minimal memory footprint: Efficient async Rust I/O
- High throughput: Actix Web + Tokio
Quick Start
Choose one way to run:
# Docker (recommended)
# Cargo
Installation
🐳 Docker
# Latest image
# Custom port
# Header filtering
📦 Cargo
# Install globally
# Run
🛠️ From Source
# Default (8080)
# Custom port
# Release build
🧰 Configuration
CLI flags:
| Option | Description | Default | Example |
|---|---|---|---|
-p, --port <PORT> |
Port number to listen on | 8080 |
--port 3000 |
--no-current-server |
Do not add current server to OpenAPI servers list |
false |
--no-current-server |
--exclude-headers <HEADERS> |
Exclude headers in responses; comma‑separated; supports wildcard suffix (e.g. x-bar-*) |
"" |
--exclude-headers "x-forwarded-*,cf-*,server" |
-h, --help |
Print help information | --help |
|
-V, --version |
Print version | --version |
Notes:
- Built‑in filtering includes reverse proxy/CDN providers (Nginx, Cloudflare, AWS, GCP, Azure).
- When using Docker, ensure
-p host:containermapping matches your--portif you override it.
Usage Examples
# Basic GET
# POST with JSON
Auth
# Basic auth
# Username only (empty password) — enhanced
Status & Redirects
# Specific status
# Random from list
# Redirect to a URL (supports form/json)
Compression & Formats
Streaming (SSE/NDJSON)
# SSE
&format=simple
&delay=2000
# NDJSON
&format=simple
&model=llama3&delay=1500
Cookies & Inspection
OpenAPI & Web UI
- OpenAPI spec:
GET /openapi.json - Web UI / API info: visit
/in a browser; renders HTML or JSON based onAcceptheader
API Reference
HTTPBin Compatibility (Overview)
- Methods:
GET /get,POST /post,PUT /put,PATCH /patch,DELETE /delete - Anything:
/anything,/anything/{anything}(supports multiple methods) - Auth: Basic, Hidden Basic, Digest
- Formats: JSON, XML, HTML,
robots.txt,encoding/utf8, gzip/deflate/brotli - Dynamic:
uuid,bytes,stream,range,links,delay,drip - Redirects:
redirect,relative-redirect,absolute-redirect,redirect-to - Inspection:
headers,ip,user-agent - Response:
cache,etag,response-headers - Cookies:
cookiesCRUD - Images:
image,image/png,image/jpeg,image/webp,image/svg - Status:
/status/{codes}(single or comma‑separated)
For the full, up‑to‑date list and schemas, consult the OpenAPI spec.
HTTPCan Enhancements
- Echo endpoint:
/echoreflects request body and headers (multi‑method) - Auth+: Basic auth with username only; JWT Bearer decode/inspect at
/jwt-bearer - Status+: Content‑type priority:
Accept> requestContent-Type> default; supports custom bodies via query/body - Redirects+:
POST /redirect-tosupportsapplication/x-www-form-urlencoded,multipart/form-data,application/json - Streaming+: SSE/NDJSON endpoints with
count,delay, and AI formats (OpenAI/Ollama) - File uploads+: Multiple files with the same field return as array across multipart endpoints
🦀 Library Usage
Add dependency:
[]
= "0.5"
Embed server:
use HttpCanServer;
async
More examples and advanced config: see LIBRARY_USAGE.md.
Development
# Run checks
# Run locally
Contributions are welcome! Please open issues/PRs for discussion.
License
MIT — see LICENSE.