/localserver
├── /src
│ ├── Main.java │ ├── /config
│ │ ├── ConfigLoader.java │ │ ├── ServerConfig.java │ │ └── RouteConfig.java │ ├── /core
│ │ ├── Server.java | | ├── ConnectionHandler.java
│ ├── /http
│ │ ├── Cookie.java │ │ ├── HttpRequest.java | | ├── HttpException.java
| | ├── HttpRequestParser.java
│ │ ├── HttpResponse.java │ │ ├── HttpStatus.java │ ├── /handlers
| | ├── CGIHandler.java │ │ ├── StaticFileHandler.java | | ├── UploadHandler.java | | ├── DeleteHandler.java | | ├── MultipartFile.java
| | ├── MultipartParser.java
│ ├── /session
│ │ ├── Session.java │ │ ├── SessionManager.java │ ├── /utils
│ │ ├── MimeTypes.java | ├── /www
├── /cgi-bin
└── README.md
chmod +x install_siege.sh
./install_siege.sh
chmod +x test_siege.sh
# Start server
make
./test_siege.shTest 1: Static Files (GET)
curl http://localhost:8091/
# Should return index.htmlTest : Simple POST
curl -X POST --data "test" http://localhost:8080/
# Returns 201 with "POST data received: 4 bytes"Test 2: Sessions
# First request
curl -b cookies.txt -c cookies.txt http://localhost:8091/session
# Output: visits=1# Second request
curl -b cookies.txt -c cookies.txt http://localhost:8091/session
# Output: visits=2Test 3: File Upload (POST) and GET file content
echo"Hello integration"> test.txt
curl -F "file=@test.txt" http://localhost:8091/uploads
# Should return JSON with upload info
curl http://localhost:8091/uploads/test.txt
# ✅ (file content)Test 4: File Delete (DELETE)
# First check file exists
ls build/uploads/test.txt
# Delete it
curl -X DELETE http://localhost:8091/uploads/test.txt
# Should return 204 No Content# Verify deleted
ls build/uploads/test.txt
# Should show: No such fileTest 5: CGI Execution
curl http://localhost:8091/api/test.py
# Should return HTML with Python CGI output
curl "http://localhost:8091/api/test.py?name=Bob"# Should show query string in outputTest 6: Method Validation
# Route "/" only allows GET
curl -X POST http://localhost:8091/
# Should return: 405 Method Not AllowedTest 7: Multi-Port
# Test different ports
curl http://localhost:8091/
curl http://localhost:8092/
curl http://localhost:8099/
# All should work(
printf"GET / HTTP/1.1\r\nHost: localhost\r\n\r\n"
sleep 2
printf"GET /test.txt HTTP/1.1\r\nHost: localhost\r\n\r\n"
sleep 2
printf"GET /style.css HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n"
sleep 1
) | nc localhost 8091Expected output:
HTTP/1.1 200 OK
...
(response 1)
HTTP/1.1 200 OK
...
(response 2)
HTTP/1.1 200 OK
...
(response 3)
Expected server logs:
[KEEP-ALIVE] Connection kept open for next request
[KEEP-ALIVE] Connection kept open for next request
[CONNECTION] Closing as requested by client
# Test 1: goats.com:
curl --resolve goats.com:8080:127.0.0.1 http://goats.com:8080/
# Test 2: test:
curl --resolve test:8080:127.0.0.1 http://test:8080/
# Test 3: Unknown host (uses default):
curl --resolve unknown.com:8080:127.0.0.1 http://unknown.com:8080/