How jeremycw/httpserver.h works
httpserver.h is a single-header C library for non-blocking, event-driven HTTP servers on Linux epoll and BSD/macOS kqueue. Its main workflow accepts a client connection, reads and parses an HTTP request, invokes the application’s request handler, then serializes and writes the response; connections can be reused or closed, and responses can be chunked. The graph separates event dispatch, request processing, response handling, and the public API. Some source is unsampled, so only documented or indexed relationships are shown; unverified links are omitted.
Main entry points: io_events.c Event dispatch · api.h Public API · read_socket.c Socket reading · server.c Server lifecycle
Components 13
Public API
- Public API
src/api.h
Event and connection runtime
- Server lifecycle
src/server.c - Connection management
src/connection.c - Event dispatch
src/io_events.c - Session state
src/common.h
Request processing
- Socket reading
src/read_socket.c - HTTP parser
src/parser.rl - Request accessors
src/request_util.c - Buffer utilities
src/buffer_util.h
Response handling
- Response construction
src/respond.c - Socket writing
src/write_socket.c
Other components
- HTTP client
- Application handler
Connections 17
- HTTP client → Server lifecycle: connects to
README.md - Public API → Server lifecycle: configures
- Public API → Request accessors: exposes
- Public API → Response construction: exposes
- Server lifecycle → Event dispatch: runs events
- Event dispatch → Connection management: accepts clients
src/io_events.c - Event dispatch → Socket reading: reads requests
src/io_events.c - Event dispatch → Socket writing: writes responses
src/io_events.c - Socket reading → HTTP parser: parses bytes
src/read_socket.c - Socket reading → Application handler: invokes handler
- Application handler → Public API: uses API
README.md - Public API → Response construction: submits response
README.md - Response construction → Socket writing: serializes response
- Request accessors → HTTP parser: reads tokens
- Event dispatch → Buffer utilities: frees buffers
src/io_events.c - Event dispatch → Session state: updates session
src/io_events.c - Connection management → Session state: manages session
src/connection.c