A high-performance, multi-threaded HTTP/1.1 server built from scratch using Java Sockets. This project demonstrates core networking concepts, manual HTTP parsing, and concurrent system design.
-
Build Tool: Maven (Dependency management and lifecycle)
-
OS Environment: Ubuntu/Linux (Targeted for deployment and testing)
-
Version Control: Git & GitHub sequenceDiagram Participant Client Participant Server Participant ThreadPool
Client->>Server: TCP Connection (Port 4221) Server->>ThreadPool: Submit handling(clientSocket) ThreadPool->>Server: Process Request (GET/POST) Server->>Client: HTTP/1.1 200 OK (with GZIP if req) Note right of Client: Connection Closed/Keep-Alive
Status Codes Implemented:
200 OK
GET
GET /echo/{text}
GET /user-agent
GET /files/{filename} when the file exists
201 Created
POST /files/{filename} when a file is successfully written
404 Not Found
Any path that doesn’t match the supported routes
GET /files/{filename} when the file does not exist
This project was developed using a Test-Driven approach. The server logic is validated against a rigorous suite of concurrent connection and protocol compliance tests.
- Environment: Tested on Ubuntu Linux to ensure POSIX socket compatibility.
- Build Lifecycle: Managed via Maven for consistent builds and dependency resolution.
- CI/CD: Integrated with automated testers to validate:
- Concurrent request handling (10+ simultaneous clients).
- GZIP compression integrity.
- File I/O edge cases (missing files, large uploads).
A basic HTTP server implemented from scratch in Java using low-level socket programming. This project focuses on understanding how HTTP works under the hood without relying on frameworks.
🧠 Technical Implementation Concurrent Processing To prevent "head-of-line blocking," the server utilizes an ExecutorService. Each incoming socket is handed off to a worker thread, allowing the main server loop to remain responsive to new connections.
Manual Protocol Parsing The server manually implements the HTTP/1.1 protocol:
Request Parsing: Extracting method, path, and headers via BufferedReader.
GZIP Logic: Using GZIPOutputStream to compress data only when the client specifies support in headers.
Connection Management: Monitoring the Connection header to determine whether to persist or terminate the socket.
🧪 Automated Testing This implementation successfully passed a rigorous suite of automated tests covering:
HTTP Compression: Proper header signaling and compression integrity.
Multiple Connections: Stress testing with simultaneous requests.
Persistent Connections: Efficiently reusing or closing sockets based on client intent.