h2o/picohttpparser
Freetiny HTTP parser written in C (used in HTTP::Parser::XS et al.)
About h2o/picohttpparser
PicoHTTPParser is a tiny, primitive, and fast HTTP request/response parser written in C. Unlike most parsers, it is stateless and does no memory allocation: it accepts a buffer pointer and an output structure, then sets pointers in the output to reference the relevant portions of the buffer. This design makes it extremely lightweight and suitable for high-performance applications. The library exposes four functions: phr_parse_request, phr_parse_response, phr_parse_headers, and phr_decode_chunked. It is widely deployed in the Perl ecosystem through modules like Plack, Starman, Starlet, and Furl, and also serves as the HTTP/1 parser in the H2O web server. The software is dual-licensed under the Perl License or the MIT License.
Key Features
Pros & Cons
- Minimal footprint and very fast parsing
- No dynamic memory allocation (zero-copy design)
- Proven in production across many Perl applications and H2O
- Simple API with only four functions
- Dual-licensed for flexible integration
- Only parses request/response line and headers – does not parse the HTTP body
- Requires manual handling of chunked encoding via separate decoder
- No URL parsing or header value decomposition – caller must process raw strings
- Minimal error reporting; returns simple integer status
- Not a full-featured HTTP library; intended as a building block