A minimal HTTP server written in x86-64 assembly for Linux, using only syscalls.
- Zero Dependencies: No
libcor external libraries. Just raw assembly and the Linux kernel. - Concurrent: Uses the
forkmodel to handle multiple incoming connections simultaneously. - Ultra Lightweight: Compiles to a tiny binary (typically < 5KB).
- I/O: Implements basic
GETandPOSTmethods for file interaction. - Pure Syscalls: Leverages
sys_socket,sys_bind,sys_fork, and more.
an example of the request flow will be:
socket → bind → listen → accept → fork → parse → open, read/write, close → respond
The codebase is modularized to separate networking logic from request handling:
| File | Description | Key Syscalls |
|---|---|---|
main.s |
The entry point (_start). Orchestrates the accept loop and process forking. |
fork, exit |
network.s |
Socket abstraction layer. Handles IPv4 binding on port 80. | socket, bind, listen, accept |
req_handler.s |
Parses HTTP headers and routes GET/POST logic. |
— |
io.s |
Lightweight wrappers for file and stream operations. | open, read, write, close |
Makefile |
Simple build script using as and ld. |
— |
You need a Linux environment with binutils (specifically as and ld) installed, which are installed by default with gcc.
To assemble and link the server, simply run:
makeNote
Port 80 requires elevated privileges on most systems, so run it with sudo
sudo make runTo make sure you have successfully started the server, open your browser and go to http://127.0.0.1/ and you should see the following page:
- Listens on IPv4
0.0.0.0:80, looking at all available interfaces - Uses a fork-per-connection model
- Reads request data into a fixed-size buffer
- Returns an HTTP response header:
HTTP/1.0 200 OK
Note
You have to provide the absolute path to the file you want to read from or write to
A basic usage example will be to run the server in a terminal then in another one do
curl http://127.0.0.1/<path-to-file>to perform a GET request, or
curl -X POST http://127.0.0.1/<path-to-file> -d "<content>"for a POST request
This project is licensed under the MIT License - see the LICENSE.md file for details
