[go: nahoru, domu]

Skip to content

Minimal C http request parser with no dependencies or memory allocations

Notifications You must be signed in to change notification settings

asimos-bot/minhttp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MinHTTP

Linux MacOS Windows (MSVC) No Dependencies Lines of Code Badge

Minimal HTTP 1.0 and 1.1 parser and builder for requests and responses.

  • no memory allocations
  • no dependencies

Inspired by picohttpparser. This project aims to have better performance and smaller size while having a builder feature.

How to Use

There is two options:

  • Build library and include it in your project
  • Just copy minhttp.c and minhttp.h to the proper locations in your project.

How to Build

  1. mkdir build/
  2. cd build/
  3. cmake .. && cmake --build .

How to Test

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.

Roadmap

  • 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)
      • get max key len automatically
  • builder
    • header builder
    • response first line builder
    • response 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
  • misc
    • add code coverage percentage
    • add documentation on how to use

About

Minimal C http request parser with no dependencies or memory allocations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published