Serves html with html templates over HTTP/1.1.
Find a file
Stephen Seo 9294108f13
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 2s
Impl. print of specific headers arg/option
TODO: Maybe refactor this to use a hash-map or something similar to
speed up the process. If N = number-of-headers-to-print and M =
size-of-request-buffer, then currrently this will take O(N*M) time.
2024-09-06 17:30:37 +09:00
.forgejo/workflows Add action/workflow to run unit tests 2024-09-04 17:51:07 +09:00
example_config Add support for different error responses 2024-09-06 15:55:21 +09:00
src Impl. print of specific headers arg/option 2024-09-06 17:30:37 +09:00
third_party Update third party submodule SimpleArchiver 2024-09-06 14:30:33 +09:00
.gitignore Add CMakeLists.txt, update .gitignore 2024-09-06 13:24:28 +09:00
.gitmodules Add third_party SimpleArchiver (data structures) 2024-08-30 11:58:11 +09:00
CMakeLists.txt Add CMakeLists.txt, update .gitignore 2024-09-06 13:24:28 +09:00
LICENSE Add the ISC LICENSE 2024-08-29 16:09:19 +09:00
Makefile Use ${CC} and "CC ?= gcc" in Makefile 2024-09-05 16:25:49 +09:00
README.md Add flag to disable peer address printing 2024-09-06 16:40:36 +09:00

C Simple HTTP

A simple HTTP/1.1 server written in C.

Usage

Usage:
  -p <port> | --port <port>
  --config=<config_file>
  --disable-peer-addr-print

Before Compiling

Make sure that the git submodule(s) are loaded:

git submodule update --init --recursive --depth=1 --no-single-branch

Without this, the project will fail to build.

Example

# Build the project.
make c_simple_http

# Alternatively, build with cmake.
cmake -S . -B buildDebug && make -C buildDebug

# Run it with the example config.
# Note that the example config was designed such that it must be referred
# to from its parent directory.
./c_simple_http --config=example_config/example.config
# If built with cmake:
./buildDebug/c_simple_http --config=example_config/example.config

# If port is not specified, the server picks a random port.
# This program should print which TCP port it is listening on.
# Sometimes the program will fail to rebind to the same port due to how TCP
# works. Either wait some time or choose a different port.

# Access the website.
# This assumes the server is hosted on port 3000.
curl localhost:3000