A lightweight, asynchronous HTTP/1.1 server implementation written in Rust using Tokio. This project demonstrates modern HTTP server architecture with support for persistent connections, chunked encoding, and comprehensive HTTP/1.1 compliance.
- Multiple HTTP Methods: GET, POST, HEAD, and more
- Persistent Connections: Keep-alive support for improved performance
- Chunked Transfer Encoding: Efficient handling of large responses
- Case-Insensitive Headers: RFC-compliant header processing
- Multi-Field Headers: Support for headers with multiple values
- Comprehensive Status Codes: Proper error handling and response codes
- Asynchronous Architecture: Built on Tokio for high concurrency
- Static File Serving: Efficient serving of static content
- MIME Type Detection: Automatic content-type detection
- CORS Support: Cross-Origin Resource Sharing headers
- Security: File access control and path validation
- Required headers (Date, Server, Connection)
- Proper request parsing and response formatting
- HTTP/1.0 and HTTP/1.1 protocol support
- Rust 1.70 or later
- Cargo package manager
- Clone the repository:
git clone https://github.com/annurdien/http-rust.git
cd http-rust- Build and run the server:
cargo run- Test the server:
# Basic GET request
curl http://127.0.0.1:7878/index.html
# With verbose output to see headers
curl -v http://127.0.0.1:7878/index.html
# POST request example
curl -X POST -d "test data" http://127.0.0.1:7878/The server will start on 127.0.0.1:7878 and serve files from the public/ directory.
The server currently serves files from the public/ directory. Allowed files are configured in the create_allowed_file_table() function in src/main.rs.
Default served files:
public/index.html- Main pagepublic/style.css- Stylesheet
This server implements a modern asynchronous architecture:
- Async/Await: Uses Tokio runtime for non-blocking I/O
- Connection Pooling: Supports multiple concurrent connections
- Request Processing: Efficient parsing and response generation
- File System: Secure file serving with access controls
For detailed architecture information, see docs/architecture.md.
This implementation supports most HTTP/1.1 features as defined in RFC 7230-7235:
- Protocol negotiation and version handling
- Request/response message format
- Header field parsing and generation
- Connection management
- Transfer encoding
For a detailed feature matrix, see docs/http1-spec.md.
cargo buildcargo checkcargo test- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source. See the repository for license details.
- Architecture Details - Server design and components
- HTTP/1.1 Specification Compliance - Feature support matrix