Provides a minimal, dependency-free HTTP/1.x request parser.
Provides a minimal, dependency-free HTTP/1.x request parser.
PicoHTTPParser is a tiny, primitive, fast HTTP request/response parser.
It only parses HTTP/1.x requests and responses. It is neither a webserver, nor an HTTP client. It does not open sockets, allocate buffer bodies or build responses. Unlike most parsers, it is stateless and does not allocate memory by itself. All it does is accept a pointer to the buffer and the output structure, and sets up the pointers in the latter to point at the necessary portions of the buffer.
The parser must be added to the Makefile with
Then, include the header file picohttpparser.h and start using the phr_parse_request or phr_parse_response functions. Both implementations do not copy the data, they only set pointers to the data in the buffer, so the buffer must remain valid during processing.
Below is a minimal example of how to use the parser to parse an HTTP request that is stored in a buffer request.
Below is a minimal example of how to use the parser to parse an HTTP response that is stored in a buffer response.