Skip to content

About

A really simple and minimal http server that may segfault sometime

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

dtypes HTTP server (starter)

A small Linux/POSIX TCP server using dtypes' hashmap as its route table. This is a learning prototype, not a production HTTP implementation.

What it does

  • Accepts one connection at a time.
  • Supports GET and HEAD.
  • Routes / and /health through dtypes hashmap.
  • 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.

Build

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=../dtypes

Run:

./server 8080

Try 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/

Important implementation note

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.

Current limits

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.
  • HEAD is handled for the two built-in routes only.

About

A really simple and minimal http server that may segfault sometime

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages