r/C_Programming • u/WingRevolutionary979 • Oct 27 '26
Project WSERVE: Web Server in C, part 2
Hi,
About a month ago, I posted about "wserve", which was a simple IPv4 web server for Linux that supported only GET and HEAD requests and static file serving. Since then I kept working on it, and implemented:
- Dynamic routing
- POST request handling with a custom JSON parser
- Most importantly, HTTPS support using BearSSL
BearSSL is the only external library I used. It is tiny SSL/TLS library written in pure C. Everything else, including the JSON parser, has been implemented in C by myself. I have not used LLMs for coding.
I am open to constructive criticism, all feedback is appreciated!
15
Upvotes
•
u/AutoModerator Oct 27 '26
Hi /u/WingRevolutionary979,
Your submission in r/C_Programming was filtered because it links to a git project.
You must edit the submission or respond to this comment with an explanation about how AI was involved in the creation of your project.
While AI-generated code is not disallowed, low-effort "slop" projects may be removed and it's likely that other users push back strongly on substantially AI-generated projects.
You can read more at https://www.reddit.com/r/C_Programming/wiki/index/posting-projects
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
10
u/canyonmonkey Oct 27 '26
Since this is for the purpose of learning, I would encourage you to add significantly more compiler & runtime warnings. I'm not an expert in this area at all, so let's go with u/skeeto's recommendations (link):
and
Additionally,
reallocis roughlymalloc -> memcpy -> free(old pointer). What if the new (implied)mallocfails? You ought to guard your reallocations (e.g. json.c:46) such as:However, I'd push back further on the memory allocation in this version of your JSON parser. There are so many allocations, reallocations, & frees. Consider learning about arena allocators and revising your parser. See skeeto's blog post for one among many learning resources.
Some additional considerations:
0x00being used as the terminating condition in json.c:40? If you're parsing JSON from a POST request, you can instead use the number of bytes in the Content-Length header as the terminating condition.strtodfails in json.c:112?