https://github.com/mayank-02/tritonhttp
Lightweight HTTP/1.1 server focused on handling GET requests efficiently, concurrency and response handling
https://github.com/mayank-02/tritonhttp
concurrency golang http1-1 networking web-server
Last synced: about 1 month ago
JSON representation
Lightweight HTTP/1.1 server focused on handling GET requests efficiently, concurrency and response handling
- Host: GitHub
- URL: https://github.com/mayank-02/tritonhttp
- Owner: mayank-02
- License: mit
- Created: 2024-06-18T05:12:34.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-30T03:03:39.000Z (almost 2 years ago)
- Last Synced: 2025-03-16T21:48:39.033Z (about 1 year ago)
- Topics: concurrency, golang, http1-1, networking, web-server
- Language: Go
- Homepage:
- Size: 1.02 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# TritonHTTP
TritonHTTP is a lightweight web server that implements a subset of the HTTP/1.1 protocol, specifically designed to handle GET requests. This project is a practical exploration of HTTP server functionalities, focusing on concurrency, request parsing, and response handling.
## Features
- Basic Web Server: Listens for connections and processes HTTP requests from clients.
- Persistent Connections: Supports reuse of TCP connections for improved efficiency.
- Request Handling: Properly parses and responds to HTTP GET requests.
- Error Responses: Implements appropriate HTTP status codes (200, 400, 404).
- Virtual Hosting: Supports multiple hostnames, mapping to unique directories.
- Timeout Mechanism: Closes connections after a configurable timeout period.
### Supported HTTP Headers
- **Request Headers**:
- `Host` (required)
- `Connection` (optional)
- **Response Headers**:
- `Date`
- `Last-Modified`
- `Content-Type`
- `Content-Length`
- `Connection`
For detailed specification, refer to `docs/theory.pdf`.
## Setup
```bash
# Clone the repository
git clone https://github.com/mayank-02/tritonhttp.git
cd tritonhttp
# Install dependencies
go mod tidy
# Run tests
go test ./...
# Run the server
go run server.go
# Open your browser and navigate to `http://localhost:PORT`.
```
## Configuration
* Virtual Hosts: Define your host-to-directory mappings in virtual_hosts.yaml.
* Server Port: Modify the default port in the configuration section of main.go if needed.
## Testing
Automated tests are provided to verify server functionality:
```
go test -v
```
You can also use command-line tools like `curl` or `netcat` to test the server responses. Example:
```bash
curl -v http://localhost:PORT/path/to/resource
```
## Contributions
Contributions are welcome! Please fork the repository and submit a pull request for review.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.