| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
| Docs | GitHub Actions | Drone | Code Coverage | |
|---|---|---|---|---|
| master | ||||
| develop |
HTTP powers the web, but implementing it correctly in C++ is surprisingly hard. Boost.HTTP gives you the entire HTTP/1.1 protocol stack — from raw parsing up to complete clients and servers — without tying you to any network library.
The library follows a Sans-I/O architecture at every layer. Even high-level clients and servers operate on abstract, type-erased stream interfaces rather than concrete sockets. There is no dependency on any networking or I/O library — not even in the implementation files. You bring your own transport.
The execution model is coroutines-only, built on Boost.Capy, a C++20 coroutine I/O foundation that provides task types, buffer sequences, stream concepts, and type-erased stream wrappers.
#include <boost/http.hpp>
using namespace boost::http;
int main()
{
// Build a request
request req(method::get, "/api/users");
req.set(field::host, "example.com");
req.set(field::accept, "application/json");
// Build a response
response res(status::ok);
res.set(field::content_type, "application/json");
res.set(field::content_length, "42");
// Access the serialized form
std::cout << req.buffer();
std::cout << res.buffer();
}Output:
GET /api/users HTTP/1.1 Host: example.com Accept: application/json HTTP/1.1 200 OK Content-Type: application/json Content-Length: 42
The Sans-I/O separation yields concrete benefits:
Reusability. The same HTTP code works with any transport. Write the protocol logic once, plug in any I/O framework.
Testability. Tests run as pure function calls without sockets, timers, or network delays. Coverage is higher, execution is faster, results are deterministic.
Security. The parser is strict by default. Malformed input that could enable request smuggling or header injection is rejected immediately.
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
| Back | FazBrowse Home | New Git URL |