@@ -15,10 +15,11 @@ A minimal HTTP server for Unix/Linux systems using fork-based concurrency. Simpl
1515
1616## Features
1717
18- - Simple routing with ` GET() ` and ` POST ()` macros
18+ - Simple routing with ` GET() ` , ` POST() ` , and ` HEAD ()` macros
1919- Static file serving from ` ./public ` directory
2020- Request header parsing and access
2121- POST payload handling
22+ - HEAD method support for checking resource existence
2223- Fork-based concurrency (up to 1000 concurrent connections)
2324- Path traversal protection
2425- Graceful shutdown with signal handling
@@ -75,31 +76,41 @@ int main() {
7576``` c
7677void route () {
7778 ROUTE_START ()
78-
79+
7980 GET ("/hello") {
8081 HTTP_200;
8182 printf("Hello, World!\n");
8283 }
83-
84+
8485 GET ("/test") {
8586 HTTP_200;
8687 // Display system information
8788 printf("Server Uptime: ...\n");
8889 printf("OS: %s\n", ...);
8990 // Full implementation in main.c
9091 }
91-
92+
9293 POST ("/data") {
9394 HTTP_201;
9495 printf("Received %d bytes\n", payload_size);
9596 // Access POST data via: payload, payload_size
9697 }
97-
98+
99+ HEAD ("/file.pdf") {
100+ // Check if resource exists without sending body
101+ if (file_exists("public/file.pdf")) {
102+ HTTP_200;
103+ // Headers sent, no body (HEAD behavior)
104+ } else {
105+ HTTP_404;
106+ }
107+ }
108+
98109 GET (uri) {
99110 // Catch-all route for static files
100111 serve_static_file(uri);
101112 }
102-
113+
103114 ROUTE_END ()
104115}
105116```
@@ -200,6 +211,7 @@ See `main.c` for a complete example. Key steps:
200211- `ROUTE_START()` - Begin route definition
201212- `GET(path)` - Define GET route
202213- `POST(path)` - Define POST route
214+ - `HEAD(path)` - Define HEAD route (returns headers only, no body)
203215- `ROUTE_END()` - End route definition
204216
205217### Request Functions
0 commit comments