https://github.com/drkwitht/h1c-http-server
First attempt at a HTTP server in C.
https://github.com/drkwitht/h1c-http-server
c http-server socket-programming toy-project
Last synced: about 1 year ago
JSON representation
First attempt at a HTTP server in C.
- Host: GitHub
- URL: https://github.com/drkwitht/h1c-http-server
- Owner: DrkWithT
- License: mit
- Created: 2023-09-10T02:42:17.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-03T05:19:57.000Z (over 2 years ago)
- Last Synced: 2025-02-09T23:30:04.084Z (over 1 year ago)
- Topics: c, http-server, socket-programming, toy-project
- Language: C
- Homepage:
- Size: 124 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# README
## Brief
This repo contains files and code for a minimal, toy HTTP/1.x server. *nix systems and Linux distros should support the C standard library and UNIX networking headers, but Windows will not. Not for production usage but for learning purposes.
## References
- [HTTP 1.x Introduction](https://jmarshall.com/easy/http/)
## Usage
- Run `make all` to build the program.
- Enter `./h1cserver` to run the server on default port 8080.
- Enter `./h1cserver n` to run the server on port n where n is at least 1024.
- Enter `make clean && make all` after changes to refresh the build.
## To Do's
1. ~~Implement response writer.~~
2. ~~Implement and fill in main server "object".~~
3. ~~Refactor server to send `Date: xxx` header.~~
4. Refactor server to use route handler logic.
- ~~Implement static resources.~~
- ~~Implement date utility and resource cache before packing them into a context object.~~
- ~~Add context argument to callback & fallback function signatures.~~
- ~~Integrate `RouteMap` into main server logic.~~
- ~~Possibly refactor server to use thread pools: `BlockedQueue`, `ServerListener`, `ServerWorker`~~
- Fix server to gracefully exit on `SIGINT`. Currently the CTRL+C keystroke does not cleanly exit: the first time only prints the exiting message. Even then there is a double free almost certainly within the called cleanup code per worker.