Minimal HTTP 1.0 and 1.1 parser and builder for requests and responses.
- no memory allocations
- no dependencies (only header used is
stdint.h
)
Inspired by picohttpparser. This project aims to have better performance and smaller size while having a builder feature.
There is two options:
- Build library and include it in your project
- Just copy
minhttp.c
andminhttp.h
to the proper locations in your project.
mkdir build/
cd build/
cmake .. && cmake --build .
In build/
: ./test
or ./test --quiet
(for no output on success).
The tests are based on the ones from picohttpparser. Be aware that changes have been made due to difference between them:
- picohttpparser allows "keyless" values. This project doesn't
- compare their
"parse multiline"
test and this project's"parse_headers_multiline_success_example_test"
and"parse_headers_multiline_example_test"
for a better visualization.
- compare their
- parsers
- pass all tests for request first line from picohttpparser
- pass all tests for header parser from picohttpparser
- pass all tests for response first line parser from picohttpparser
- parse only requested headers (
mh_parse_headers_set
)
- builder
- header builder
- response first line builder
- request first line builder
- benchmarking and optimizations
- benchmark against other http parsers
- picohttpparser
- straight-forward parsing with no state machine
- add likely and unlikely in all appropriate jumps
- separate benchmark for header parsing and for first line parsing
- enable NULL arguments for faster parsing
- benchmark against other http parsers
- misc
- add code coverage percentage
- add documentation on how to use