Skip to content

Instantly share code, notes, and snippets.

@vinipsmaker
Created March 13, 2017 05:44
Show Gist options
  • Save vinipsmaker/2685bcd09a6ebcae0267be61562c2347 to your computer and use it in GitHub Desktop.
Save vinipsmaker/2685bcd09a6ebcae0267be61562c2347 to your computer and use it in GitHub Desktop.

Boost.Http

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

This library can be used to create applications that need to expose services through HTTP (e.g. embeddable ReST services).

Warning
This is not an official Boost C++ library. It wasn’t reviewed and can’t be downloaded from www.boost.org. This library will be reviewed eventually.

Boost.Http is a library that provides an incremental HTTP parser and a set of mini-parsers that can be used independently or combined [1]. A future version will also provide a message generator.

The highlights are:

  • Support for modern HTTP features.

  • Simple.

  • Portable (C++03 and little dependencies).

  • Just like Ryan Dahl’s HTTP parser, this parser does not make any syscalls nor allocations, it does not buffer data.

  • You can mutate the passed buffer [2].

  • It doesn’t steal control flow from your application [3]. Great for HTTP pipelining.

  • Matching and decoding token as separate steps [4].


1. parser combinators algorithms are on the way to ease it up even further. Check the talk from Scott Wlaschin for more.
2. The larger explanation being: incomplete tokens are kept in buffer, so you are not required to allocate them on a secondary buffer, but you’re still allowed to mutate/move/grow the buffer.
3. parsing is done one token at a time no matter how much data is buffered
4. Proper extraction of header fields (some popular parsers like NodeJS’s will force you to know protocol details and parser internals to manually remove leading and trailing whitespace from field values). This point is not only about header field extraction, but really about a parser that indeed abstract and understand the protocol and that is easy to use right by people that don’t know HTTP.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment