LITH is a minimalist, high-performance, multi-threaded HTTP engine implemented in standard C11. Engineered to be exceptionally lightweight, modular, and portable, it provides native support for Windows (via w64devkit/MinGW-w64 and Winsock2), macOS, and Linux systems. It is designed with robust network lifecycle management, resource-efficient concurrency handlers, and zero external software dependencies.
- Architectural Thread Pool: Instantiates a fixed set of permanent, isolated worker threads upon boot. Eliminates runtime thread spawning/destruction overhead by utilizing a synchronized FIFO task queue managed via POSIX condition variables (
pthread_cond_t) and mutexes (pthread_mutex_t). - Native Background Daemon Mode (v1.0.8 Linux Only): Detaches the server process from the controlling terminal using a strict dual-
fork()POSIX sequence. Isolates the process session (setsid()), resets the file creation mask (umask(0)), and seamlessly redirects standard output and error streams to a continuous localizedlith.logfile. - High-Throughput Main Loop: Features an optimized accept-loop that offloads incoming sockets instantly to the shared worker pool, freeing the core network thread to handle maximum incoming connection density per second.
- HTTP Keep-Alive Persistent Connections: Keeps client sockets active for consecutive resource transfers within a secure window. Features automated connection recycling to maximize performance and minimize TCP handshake overhead.
- Anti-Slowloris Security Guard: Arms incoming sockets with a rigid 3-second network receive timeout (
SO_RCVTIMEO) directly on the accept layer, ensuring resilient defense against slow-connection or resource-exhaustion vector attacks. - Advanced I/O POST Payload Streaming: Features automated network stream processing to fully parse incoming HTTP
POSTrequests, handling chunked or fragmented bodies using preciseContent-Lengthtracking and multi-stage buffer safety boundaries. - Thread-Safe Isolated Configuration: Passes critical runtime data (such as the web root asset path) directly inside the thread pool context, completely removing reliance on shared static global variables or race-prone states.
- External Configuration Engine: Dynamically loads runtime environments from a
lith.confconfiguration file without requiring binary recompilation. - Dynamic MIME Type Resolution: Automatically maps file extensions to their corresponding IANA media types (
.html,.css,.js,.json,.png, etc.) for proper browser rendering. - Unified Security & Path Filters: Protects against directory traversal vulnerabilities by parsing, validating, and rejecting malicious relative path patterns such as
... - Unified Error Canvas Layouts: Serves clean, dark-themed HTML error pages for common HTTP status codes (
400,403,404,408, and500).
LITH ships with a highly robust, cross-platform Makefile optimized for GNU Make. It automatically handles header dependency generation (-MMD -MP) and natively adapts to both Linux/macOS shells and Windows environments (such as w64devkit).
To compile the project from scratch:
make clean
makeLITH loads its runtime configuration from a file named lith.conf located in the application's root directory.
# Network listening port
PORT=8090
# Directory containing static web assets
PUBLIC_DIR=publicPlace your web assets inside the configured public/ directory(e.g., public/index.html)..
LITH features a modern, explicit CLI command architecture. To execute the engine, you must use the start command routing path:
# Launch the engine in the foreground using standard configuration settings
bin/lith start
# Override the configured port dynamically via runtime arguments
bin/lith start 8080
# Launch as a background daemon process detached from the terminal (Linux only)
bin/lith start 8080 --daemonNote on Windows Portability: If the --daemon or -d flag is invoked under Windows, LITH will catch the argument, log an informative warning indicating that background daemons require a UNIX environment, and gracefully fall back to foreground mode to maintain continuous execution.
To display context help or print the build version string:
bin/lith --help
bin/lith --version.
├── bin/ # Output directory for compiled executable binaries
├── include/ # Header files, macros, and cross-platform abstractions
│ ├── common.h # Centralized data structures and configuration state variables
│ ├── config.h # Runtime environment initialization prototypes (lith.conf parser)
│ ├── http_parser.h # HTTP Request structures, MIME mapping, and error pages
│ ├── http_router.h # Application routing and static file rendering logic
│ ├── logger.h # Centralized thread-safe logging interface
│ ├── server.h # Thread pool definitions, worker prototypes, and socket contexts
│ └── server_utils.h # Multiplatform OS socket wrappers and safety tools
├── public/ # Static web root (HTML, CSS, JS, Assets)
├── src/
│ ├── server/ # Configuration parser and server utility modules
│ │ ├── config.c # Runtime initialization logic (lith.conf reader)
│ │ └── utils.c # Multiplatform OS abstractions and file system safety
│ ├── daemon.c # UNIX-exclusive dual-fork background process daemonizer (v1.0.8)
│ ├── http_parser.c # Case-insensitive protocol parser
│ ├── http_router.c # Request handler, route dispatcher, and security validation
│ ├── logger.c # Formatted terminal output subsystem
│ ├── main.c # Application bootstrap, CLI routing argument handler, and signal trapping
│ ├── server.c # TCP socket initialization, reuse options, and accept-push loop
│ └── server_worker.c # Persistent pool worker thread loop, queue management, and request routing
├── lith.conf # Runtime configuration file
├── resources.rc # Windows application meta-properties and icon descriptor
└── Makefile # Universal, multi-platform automated build pipeline
| Parameter | Default Value | Description |
|---|---|---|
LITH_VERSION |
1.0.8 |
Current stable release version |
BUFFER_SIZE |
4096 bytes |
Standard socket read/write block buffer size |
| Maximum Buffer | 16 KB |
Maximum cumulative buffer space for HTTP headers and POST bodies |
BACKLOG |
10 |
Maximum number of pending client connections in the listen queue |
| Keep-Alive Timeout | 3 seconds |
SO_RCVTIMEO window before cleanly recycling a persistent socket |
MAX_KEEP_ALIVE_REQUESTS |
100 |
Maximum requests processed per single client TCP session |
This software is distributed under the terms of the FomaDev Public License (FPL). Under this license, personal and educational use of compiled binaries is free, including within corporate environments. Commercial republication, direct source-code integration into competitive proprietary tools, or maintaining standalone independent forks is strictly restricted without explicit commercial authorization. For complete licensing terms, consult the accompanying LICENSE file.