A small Linux/POSIX TCP server using dtypes' hashmap as its route table.
This is a learning prototype, not a production HTTP implementation.
- Accepts one connection at a time.
- Supports
GETandHEAD. - Routes
/and/healththroughdtypeshashmap. - Returns 400 for malformed/unsupported HTTP versions, 404 for unknown routes, 405 for unsupported methods, and 413 for oversized headers.
- Closes each connection after one response.
Expected layout:
workspace/
├── dtypes/ # clone https://github.com/curious-builder76/dtypes
│ ├── build.sh
│ ├── hashmap.h
│ └── ...
└── dtypes-http-server/ # this project
├── Makefile
└── src/server.c
Build dtypes first:
cd ../dtypes
./build.sh
cd ../dtypes-http-server
make DTYPES_DIR=../dtypesRun:
./server 8080Try it:
curl -i http://127.0.0.1:8080/
curl -i http://127.0.0.1:8080/health
curl -i http://127.0.0.1:8080/missing
curl -I http://127.0.0.1:8080/The route table uses fixed-size, zero-padded 64-byte path keys. This matches the
current hashmap_new(key_size, value_size) API, which hashes/compares fixed-size
key bytes rather than C strings. Handler function pointers are stored by value.
The pointer returned by hashmap_get is copied immediately.
This is intentionally the first milestone, not a full HTTP/1.1 implementation:
- Single-threaded and blocking; one slow client blocks others.
- It reads only request headers and does not implement request bodies.
- No keep-alive, chunked transfer coding, TLS, virtual hosts, or static files.
- Request parsing is deliberately minimal; it is not suitable for untrusted public traffic as-is.
HEADis handled for the two built-in routes only.