Description
Beast is a new header-only library using Boost that offers HTTP and WebSocket support (disclaimer: I'm the principal architect). Here's the home page with links to the repository, documentation, example code, and Autobahn test results (for the WebSocket component):
http://vinniefalco.github.io/
I'm wondering if this library could be a useful building block for cpprestsdk? There's some overlap in functionality and I think that Beast offers some very interesting design choices which at worst could serve as inspiration for future improvements to cpprestsdk and at best might be sufficiently useful as to motivate use of the library directly in the project.
For example, I notice in the cpprestsdk that the message model (class http_msg_base
) conflates both message representation and message serialization/sending:
class http_msg_base
{
...
_ASYNCRTIMP void set_body(const concurrency::streams::istream &instream,
const utf8string &contentType);
Beast solves this problem a different way, the message model supports a Body
template argument with traits that give instructions on how the message is serialized. The choice of body controls the container used to represent the body (for example, std::string
, a boost::asio::streambuf
, or a user-defined type) and the means to serialize that body to a set of buffers:
beast::http::message
class
https://github.com/vinniefalco/Beast/blob/47eb7fcc2f30df883b0036d97aac6a0fa90b0e9f/include/beast/http/message.hpp#L49
Body
concept:
http://vinniefalco.github.io/beast/beast/types/Body.html
Writer
concept (serializes the body)
http://vinniefalco.github.io/beast/beast/types/Writer.html
Here's an example of a type that meets the requirements of the Body
concept:
https://github.com/vinniefalco/Beast/blob/47eb7fcc2f30df883b0036d97aac6a0fa90b0e9f/examples/file_body.hpp#L32
Beast also offers a WebSocket implementation that follows Asio best practices and has quite a few things going for it
Beast is targeted not at end-user developers who want to do simple things like fetch a webpage or submit a request to a REST service but instead is aimed at library writers, I think this might be a good fit.