This is a simple HTTP server inspired by Tornado Web Server, for practising my Linux programming skills. No third-party libraries are used, only glibc.
This project is still a work-on-progress. But several features are already implemented:
- ioloop/iostream: Async IO module inspired by Tornado
- buffer: Simple ring-buffer module
- http: Core HTTP related features like protocol parser, handler architecture, etc.
- virtual host: Simple virtual host support.
- location config: Simple location configuration mechanism based on URI prefix and regex.
- module architecture: An simple module architecture to easily add new modules
- mod_static: A module that could serve static files and support basic MIME mapping, cache-control, welcome files, directory listing, ranged request (partially).
A lot work needs to be done, but it won't stop you from trying the features already implemented. Please refer to the following sections for instructions on how to run it.
Run make in the src
dir:
cd src
make
The target executable files will appear in the same directory. There
are several unit test cases and a main program breeze
.
Run the following command in src
directory:
./breeze [-c configfile] [-t]
If -c
is not specified, then /etc/breeze.conf
is used. If -t
is
specified, the program will print the details of the config and exits.
Please refer to the following sections for details about the config file.
Run the following command in src
directory:
./breeze [-r root_dir] [-p port]
This mode is activated with the -r
option. When activated, breeze
will not read config file. Instead, breeze will setup a simple server
serving content in the root_dir
. In this mode, the directory listing
feature is enabled. Therefore this is a perfect replacement of Python
SimpleHTTPServer. Use -p
to specify the port, by default 8000
is
used.
Run the following command in src
directory:
./test_http_server
A server on port 8000 will be started. It will return a short HTML for any request on port 8000.
Please refer to the sample config file for an example. Please note that some config options are not implemented yet.
- Automatically close keep-alive connection on server side
- HTTP chunked encoding, gzip compression
- FastCGI support
- File upload module
- Master-worker multi-process architecture
- The server stops responding to any request on high load (>2000 concurrent connections)
GPLv3