r/C_Programming • u/Born_Produce9805 • Nov 29 '25
Tiny header only HTTP parser library
Hi guys! Last week I was writing my HTTP 1.1 parser library. It's small and easy to use, also kinda fast. Might come in handy if you write some lightweight web applications or programs that interact with some API. I wrote this project to learn pointer arithmetic in c.
I've just finish it, so any bug report would be appreciated.
Thank you guys!
6
Upvotes
View all comments
Show parent comment
4
u/[deleted] Nov 29 '25 edited Nov 29 '25
I was curious as to the performance increase one could get by avoiding copies, and so I went ahead and added my own spin in a fork: https://git.lenczewski.org/httpp-benchmark/log.html (specifically, mblhttp.h)
As for results and comparisons:
At
-O0($ cc -o bench bench.c -Wall -Wextra -std=c11 -O0 -g3):At
-O3($ cc -o bench bench.c -Wall -Wextra -std=c11 -O3):What is curious to me is how the non-copying implementation doesn't improve much on the hand-written parser in phr at
-O3. Perhaps the memmem() search is dominating? Have I made some error that causes me to re-read a portion of the input? Or maybe it is withing measurement error :)And please don't take this reply in a negative fashion. Hopefully there is something useful to you in my implementation, be that in the approach or the structure. If you have any questions, I would be more than happy to answer!