nodejs/http-parser logo

nodejs/http-parser

Free

http request/response parser for c

FreeFree tier
Type
Open Source

About nodejs/http-parser

http-parser is a lightweight, high-performance HTTP message parser written in C, designed for use in performance-critical HTTP applications such as web servers and clients. It parses both HTTP requests and responses without making any syscalls or allocations, does not buffer data, and can be interrupted at any time. The parser requires approximately 40 bytes of data per message stream and supports persistent connections (keep-alive), chunked transfer encoding, and protocol upgrades. It also defends against buffer overflow attacks. The parser extracts header fields and values, Content-Length, request method, response status code, Transfer-Encoding, HTTP version, request URL, and message body. Note: this repository is archived and no longer actively maintained; new projects are advised to use llhttp instead.

Key Features

No dependencies on external libraries
Handles persistent streams (keep-alive)
Decodes chunked transfer encoding
Supports HTTP protocol upgrades (e.g., WebSocket)
Defends against buffer overflow attacks
Minimal memory footprint (~40 bytes per connection)
Does not make syscalls, allocate memory, or buffer data
Interruptible at any time during parsing
Extracts headers, method, status, URL, version, and body

Pros & Cons

Pros
  • Extremely lightweight and fast, ideal for performance-sensitive applications
  • No runtime allocations or syscalls, reducing latency and overhead
  • Small memory footprint per connection
  • Robust handling of chunked encoding and persistent connections
  • Includes buffer overflow protection for security
  • Simple C API with callback-based event handling
Cons
  • No longer actively maintained; repository is archived and read-only
  • Only supports HTTP/1.x (no HTTP/2 or HTTP/3)
  • Written in C, requiring manual memory management in host application
  • Users are encouraged to migrate to llhttp for ongoing support
  • Limited documentation beyond the README

Best For

Embedded in high-performance web servers and HTTP frameworksCustom HTTP client libraries requiring minimal overheadNetwork applications needing HTTP message parsing in resource-constrained environmentsParsing HTTP/1.x traffic for analysis or middleware

FAQ

Is http-parser still maintained?
No, the repository was archived by the owner on November 6, 2022, and is now read-only. New projects should consider using llhttp instead.
What license is http-parser released under?
The project is licensed under the MIT License (see LICENSE-MIT file in the repository).
Does http-parser support persistent connections?
Yes, it handles persistent streams (keep-alive) and decodes chunked transfer encoding for both requests and responses.
How is http-parser used in an application?
One http_parser object is used per TCP connection. You initialize it with http_parser_init(), set callback functions for events like on_url or on_header_field, and then feed data to http_parser_execute() as it arrives from the socket.