A lightweight, custom-built HTTP server implemented in Java without relying on built-in tools.
- Supports GET and POST requests
- GZip compression
- File transfers
- Multiple concurrent connections
- Custom request dispatcher for routing
- Java JDK 21 or higher
- Maven
- Clone the repository:
git clone https://github.com/aryanbk/mini-http-server - Navigate to the project directory:
cd mini-http-server - Build the project:
mvn package - Run the server:
or
./mini_http_server.shjava -jar target/mini-http-server-1.0-SNAPSHOT.jar
Run the server using the following command:
mvn exec:java -Dexec.mainClass="com.aryanbk.minihttp.Server"
Options:
--directory <path>: Specify the directory for file operations
The server handles various types of requests:
- GET /: Returns a 200 OK response
- GET /echo/: Echoes the message back
- GET /user-agent: Returns the User-Agent header
- GET /files/: Retrieves a file from the specified directory
- POST /files/: Uploads a file to the specified directory
Main.java: Entry point of the applicationClientHandler.java: Handles individual client connectionsHttpRequest.java: Parses and represents HTTP requestsHttpResponse.java: Builds and represents HTTP responsesRequestHandler.java: Routes requests to appropriate handlers