| Crates.io | httpcan |
| lib.rs | httpcan |
| version | 0.2.0 |
| created_at | 2025-09-23 17:57:27.27805+00 |
| updated_at | 2025-09-24 17:50:55.014015+00 |
| description | A simple HTTP Request & Response Service, with httpbin compatibility |
| homepage | https://github.com/seedvector/httpcan |
| repository | https://github.com/seedvector/httpcan |
| max_upload_size | |
| id | 1851860 |
| size | 3,290,842 |
A simple HTTP request & response service built with Rust and Actix Web, with httpbin compatibility.
This server implements the HTTPBin API with the following endpoints:
GET /get - Returns request data for GET requestsPOST /post - Returns request data for POST requestsPUT /put - Returns request data for PUT requestsPATCH /patch - Returns request data for PATCH requestsDELETE /delete - Returns request data for DELETE requests/anything - Accepts GET, POST, PUT, PATCH, DELETE, TRACE/anything/{anything} - Same as above with path parameterGET /basic-auth/{user}/{passwd} - Basic authenticationGET /hidden-basic-auth/{user}/{passwd} - Basic auth with 404 on failureGET /bearer - Bearer token authenticationGET /digest-auth/{qop}/{user}/{passwd} - Digest authenticationGET /digest-auth/{qop}/{user}/{passwd}/{algorithm} - Digest auth with algorithmGET /digest-auth/{qop}/{user}/{passwd}/{algorithm}/{stale_after} - Full digest authGET /json - Returns JSON responseGET /xml - Returns XML responseGET /html - Returns HTML responseGET /robots.txt - Returns robots.txtGET /deny - Returns denied messageGET /encoding/utf8 - Returns UTF-8 encoded responseGET /gzip - Returns gzip-compressed responseGET /deflate - Returns deflate-compressed responseGET /brotli - Returns brotli-compressed responseGET /uuid - Returns a UUID4GET /base64/{value} - Decodes base64-encoded stringGET /bytes/{n} - Returns n random bytesGET /stream-bytes/{n} - Streams n random bytesGET /stream/{n} - Streams n JSON responsesGET /range/{numbytes} - Returns bytes with range supportGET /links/{n}/{offset} - Returns page with n linksGET /drip - Drips data over time/delay/{delay} - Returns delayed response (supports multiple methods)GET /redirect/{n} - 302 redirects n timesGET /relative-redirect/{n} - Relative 302 redirects n timesGET /absolute-redirect/{n} - Absolute 302 redirects n times/redirect-to - 302 redirects to given URL (supports multiple methods)GET /headers - Returns request headersGET /ip - Returns client IP addressGET /user-agent - Returns User-Agent headerGET /cache - Returns 304 if caching headers presentGET /cache/{value} - Sets Cache-Control headerGET /etag/{etag} - Returns given ETagGET /response-headers - Returns custom response headers from queryPOST /response-headers - Returns custom response headers from queryGET /cookies - Returns cookiesGET /cookies/set - Sets cookies from query stringGET /cookies/set/{name}/{value} - Sets specific cookieGET /cookies/delete - Deletes cookies from query stringGET /image - Returns image based on Accept headerGET /image/png - Returns PNG imageGET /image/jpeg - Returns JPEG imageGET /image/webp - Returns WebP imageGET /image/svg - Returns SVG image/status/{codes} - Returns given status code or random from list (supports multiple methods)GET /sse - Server-Sent Events endpoint with configurable event count, delay, and formatGET /sse/{count} - SSE with specified event countGET /sse/{count}/{delay} - SSE with specified event count and delayGET /ndjson - NDJSON streaming endpoint with configurable parametersGET /ndjson/{count} - NDJSON with specified event countGET /ndjson/{count}/{delay} - NDJSON with specified event count and delayhttpcan [OPTIONS]
Options:
-p, --port <PORT> - Port number to listen on (default: 8080)--no-current-server - Do not add current server to OpenAPI specification servers list--exclude-headers <HEADERS> - Exclude specific headers from responses. Comma-separated list of header keys, supports wildcard suffix matching (e.g., "foo, x-bar-*"). Built-in filtering for Nginx, Cloudflare, AWS, GCP, and Azure headers-h, --help - Print help information-V, --version - Print version information# Default port 8080
cargo run
# Custom port
cargo run -- --port 3000
# Exclude headers
cargo run -- --exclude-headers "foo, x-bar-*"
# Multiple options
cargo run -- --port 3000 --no-current-server --exclude-headers "foo, x-bar-*"
The server will start on http://0.0.0.0:8080 (or specified port)
# Basic GET request
curl http://localhost:8080/get
# POST with JSON data
curl -X POST http://localhost:8080/post \
-H "Content-Type: application/json" \
-d '{"key": "value"}'
# Multiple HTTP methods on same endpoint
curl -X PUT http://localhost:8080/anything
curl -X DELETE http://localhost:8080/anything
# Generate UUID
curl http://localhost:8080/uuid
# Basic authentication
curl -u username:password http://localhost:8080/basic-auth/username/password
# Get compressed response
curl -H "Accept-Encoding: gzip" http://localhost:8080/gzip
# Status codes
curl http://localhost:8080/status/418
curl http://localhost:8080/status/200,404,500 # Random selection
# Server-Sent Events
curl http://localhost:8080/sse?count=3&format=simple
curl http://localhost:8080/sse/5?format=openai&delay=2000
curl http://localhost:8080/sse?format=custom&message="Hello%20World"
# NDJSON streaming
curl http://localhost:8080/ndjson?count=3&format=simple
curl http://localhost:8080/ndjson/5?format=ollama&model=llama3&delay=1500
curl http://localhost:8080/ndjson?format=openai&count=2
This project is licensed under the MIT License - see the LICENSE file for details.