A minimal HTTP server written in C, built from scratch without external libraries. The project focuses on the implementation of core data structures used to manage connections and parse HTTP requests.
- TCP server listening on port
6700 - HTTP/1.1 request parsing (request line, headers, body)
- Custom implementations of common data structures
- Leveled logging system (DEBUG, NOTICE, WARNING)
- AddressSanitizer support for debugging
server-http/
├── src/
│ ├── main.c # Server entry point, connection loop
│ ├── network.c / network.h # TCP socket abstraction (accept, send, recv)
│ ├── request.c / request.h # HTTP request parser
│ ├── data-struct/
│ │ ├── linkedList.c/h # Doubly linked list with iterator
│ │ ├── queue.c/h # Queue built on top of the linked list
│ │ └── dictionary.c/h # Hash map with FNV-1 hashing
│ └── malloc-utils/
│ └── malloc_utils.c/h # Safe malloc wrappers
└── test/
└── unit/
└── client_test.tcl # Basic client test script
| Structure | Description |
|---|---|
| Linked List | Generic doubly linked list with head/tail pointers and a bidirectional iterator |
| Queue | Wrapper over the linked list exposing push, pop, and peek operations |
| Dictionary | Hash map using separate chaining; supports string and integer keys; uses FNV-1 hashing |
Requires gcc and make.
# Build the server
make all
# Build with AddressSanitizer
make bug-compile
# Clean build artifacts
make clean
# Show available targets
make helpStart the server (listens on port 6700 by default):
./server-httpSend a test request:
curl http://localhost:6700/
# → Hello World!- The server handles one connection at a time (no threading or
select/epollyet). - The current response is a static
200 OKwithHello World!regardless of the request. - The
dicttype is used internally to store parsed request-line fields (method, URI) and header fields.