This project is a HTTP server in C.
The goal of this project is to understand the HTTP protocol and its internals by implementing a whole server in C using only the standard C library.
To build the server just go to the root directory of the cloned repository and:
$ git clone https://github.com/maxencejded/HTTP-Server.git server
$ cd server
$ make
$ ./server
Starting new Server
Adrress: 0.0.0.0:6060
The Makefile
makes use of GNU-specific features. On BSDs make sure to install GNU make from pkgsrc/ports and invoke it as gmake
.
If you want to add your website, you'll be expected to insert it in the site
subdirectory. The file index.html
should be at the root of the subdirectory.
If you are willing to add APIs, you'll have to create them in the api
subdirectory:
$ cd api/
The demo file is an api to show you how you should format your content.
Don't forget that you will have to print the HTTP header by yourself.
Finally, you are expected to add the name in the API array. Don't forget to increase the size of the number of API_COUNT
.
$ vim includes/api.h
# define API_COUNT 1 /* NUMBER OF APIs */
int demo(t_http *request, t_reponse *answer);
/* Add your functions here */
Tests will be available soon. They are being written.
Usage: ./server [OPTIONS] │
│
OPTIONS: │
-w <DIR> Web server directory (default: site) │
-p <PORT> TCP port of server listen socket (default: 6060) │
-h Produces this information to stdout.
So far tested to be compatible with macOS (darwin x86_64
), Linux (both x86_64
and ARMv7) and NetBSD as well as Android (NDK, bionic libc).
We are currently working on making it available for other UNIX systems.
- Jules Spender - Initial work - spenderj
- Maxence Jacques de Dixmude - Initial work - maxencejded
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details.
HTTP protocol, Parsing, Dynamic memory management, Optimization, Debugging, Error management