A lightweight HTTP server implemented in pure Java without any external dependencies. This project demonstrates low-level networking, HTTP protocol handling, and concurrent programming concepts.
- Custom TCP socket implementation
- HTTP/1.1 protocol support
- Multithreaded request handling
- Static file serving
- Custom routing system
- Support for GET and POST methods
- Basic request/response logging
src/
├── main/
│ └── java/
│ └── com/
│ └── httpserver/
│ ├── core/
│ │ ├── HttpServer.java # Main server class
│ │ ├── RequestHandler.java # Handles client connections
│ │ └── ServerConfig.java # Server configuration
│ ├── http/
│ │ ├── HttpRequest.java # HTTP request parser
│ │ ├── HttpResponse.java # HTTP response builder
│ │ └── HttpHeaders.java # HTTP headers utility
│ ├── router/
│ │ ├── Router.java # Request routing
│ │ └── Route.java # Route definition
│ └── Main.java # Entry point
└── resources/
└── static/ # Static files directory
└── index.html
- Clone the repository
- Run
javac src/main/java/com/httpserver/Main.java - Run
java src.main.java.com.httpserver.Main - Server will start on port 8080 (configurable)
# GET request
curl http://localhost:8080/hello
# POST request
curl -X POST -d "message=hello" http://localhost:8080/echo
# Serve static file
curl http://localhost:8080/index.html