Skip to content

Collaboration with Beast? #144

Closed
Closed
@vinniefalco

Description

@vinniefalco

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);

https://github.com/Microsoft/cpprestsdk/blob/3070ca21ed665a5aeb7d0cfe28f7f21d6c062a92/Release/include/cpprest/http_msg.h#L236

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions