diff --git a/README.md b/README.md index 00cce6fc..972ee1e9 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,13 @@ int main() // Normal boost::asio setup std::string const host = "echo.websocket.org"; boost::asio::io_service ios; - boost::asio::ip::tcp::resolver r(ios); - boost::asio::ip::tcp::socket sock(ios); + boost::asio::ip::tcp::resolver r{ios}; + boost::asio::ip::tcp::socket sock{ios}; boost::asio::connect(sock, r.resolve(boost::asio::ip::tcp::resolver::query{host, "80"})); // WebSocket connect and send message using beast - beast::websocket::stream ws(sock); + beast::websocket::stream ws{sock}; ws.handshake(host, "/"); ws.write(boost::asio::buffer("Hello, world!")); @@ -87,8 +87,8 @@ int main() // Normal boost::asio setup std::string const host = "boost.org"; boost::asio::io_service ios; - boost::asio::ip::tcp::resolver r(ios); - boost::asio::ip::tcp::socket sock(ios); + boost::asio::ip::tcp::resolver r{ios}; + boost::asio::ip::tcp::socket sock{ios}; boost::asio::connect(sock, r.resolve(boost::asio::ip::tcp::resolver::query{host, "http"})); diff --git a/doc/Jamfile b/doc/Jamfile index d01728e0..35e11311 100644 --- a/doc/Jamfile +++ b/doc/Jamfile @@ -15,7 +15,7 @@ using boostbook ; using quickbook ; using doxygen ; -xml beast_boostbook : beast.qbk ; +xml beast_boostbook : master.qbk ; path-constant out : . ; diff --git a/doc/design.qbk b/doc/design.qbk index 038c3dbd..b6562090 100644 --- a/doc/design.qbk +++ b/doc/design.qbk @@ -192,9 +192,9 @@ start. Other design goals: [websocketpp] ][ [``` - template + template void - read(opcode& op, Streambuf& streambuf) + read(opcode& op, DynamicBuffer& dynabuf) ```] [ // @@ -339,9 +339,9 @@ start. Other design goals: [@https://github.com/zaphoyd/websocketpp/blob/378437aecdcb1dfe62096ffd5d944bf1f640ccc3/websocketpp/connection.hpp#L473 also]] ][ [``` - template + template typename async_completion::result_type - async_read(opcode& op, Streambuf& streambuf, ReadHandler&& handler); + async_read(opcode& op, DynamicBuffer& dynabuf, ReadHandler&& handler); ```] [``` typedef lib::function message_handler; @@ -365,7 +365,7 @@ start. Other design goals: ][ [``` beast::async_completion completion(handler); - read_op{ + read_op{ completion.handler, *this, op, streambuf}; return completion.result.get(); ```] diff --git a/doc/http.qbk b/doc/http.qbk index 814600c3..81b89f48 100644 --- a/doc/http.qbk +++ b/doc/http.qbk @@ -92,19 +92,20 @@ and its customization points in more depth, for advanced applications. [heading Declarations] To do anything, a message must be declared. The message class template -requires at mininum, a value indicating whether the message is a request +requires at minimum, a value indicating whether the message is a request (versus a response), and a `Body` type. The choice of `Body` determines the kind of container used to represent the message body. Here we will -declare a request that has a `std::string` for the body container: +declare a HTTP/1 request that has a `std::string` for the body container: ``` - http::message req; + http::message_v1 req; ``` Two type aliases are provided for notational convenience when declaring -messages. These two statements declare a request and a response respectively: +HTTP/1 messages. These two statements declare a request and a response +respectively: ``` - http::request req; - http::response resp; + http::request_v1 req; + http::response_v1 resp; ``` [heading Members] @@ -113,14 +114,14 @@ Message objects are default constructible, with public access to data members. Request and response objects have some common members, and some members unique to the message type. These statements set all the members in each message: ``` - http::request req; - req.method = http::method_t::http_get; + http::request_v1 req; + req.method = "GET"; req.url = "/index.html"; req.version = 11; // HTTP/1.1 req.headers.insert("User-Agent", "hello_world"); req.body = ""; - http::response resp; + http::response_v1 resp; resp.status = 404; resp.reason = "Not Found"; resp.version = 10; // HTTP/1.0 @@ -128,17 +129,6 @@ to the message type. These statements set all the members in each message: resp.body = "The requested resource was not found."; ``` -The following statements achieve the same effects as the statements above: -``` - http::request req({http::method_t::http_get, "/index.html", 11}); - req.headers.insert("User-Agent", "hello_world"); - req.body = ""; - - http::response resp({404, "Not Found", 10}); - resp.headers.insert("Server", "Beast.HTTP"); - resp.body = "The requested resource was not found."; -``` - [heading Headers] The `message::headers` member is a container for setting the field/value @@ -146,7 +136,7 @@ pairs in the message. These statements change the values of the headers in the message passed: ``` template - void set_fields(http::request& req) + void set_fields(http::request_v1& req) { if(! req.exists("User-Agent")) req.insert("User-Agent", "myWebClient"); @@ -168,7 +158,10 @@ following types, provided by the library, are suitable choices for the * [link beast.ref.http__empty_body [*`empty_body`:]] An empty message body. Used in GET requests where there is no message body. Example: ``` - http::request req({http::method_t::http_get, "/index.html", 11}); + http::request_v1 req; + req.version = 11; + req.method = "GET"; + req.url = "/index.html"; ``` * [link beast.ref.http__string_body [*`string_body`:]] A body with a @@ -177,7 +170,7 @@ or response with simple text in the message body (such as an error message). Has the same insertion complexity of `std::string`. This is the type of body used in the examples: ``` - http::response resp; + http::response_v1 resp; static_assert(std::is_same::value); resp.body = "Here is the data you requested"; ``` @@ -197,7 +190,10 @@ functions: ``` void send_request(boost::asio::ip::tcp::socket& sock) { - http::request req({http::method_t::http_get, "/index.html", 11}); + http::request req; + req.version = 11; + req.method = "GET"; + req.url = "/index.html"; ... http::write(sock, req); // Throws exception on error ... @@ -213,7 +209,7 @@ An asynchronous interface is available: ``` void handle_write(boost::system::error_code); ... - http::request req; + http::request_v1 req; ... http::async_write(sock, req, std::bind(&handle_write, std::placeholders::_1)); ``` @@ -228,7 +224,7 @@ stored in the streambuf parameter for use in a subsequent call to read: ``` boost::asio::streambuf sb; ... - http::response resp; + http::response_v1 resp; http::read(sock, sb, resp); // Throws exception on error ... // Alternatively @@ -245,7 +241,7 @@ called: void handle_read(boost::system::error_code); ... boost::asio::streambuf sb; - http::response resp; + http::response_v1 resp; ... http::async_read(sock, resp, std::bind(&handle_read, std::placeholders::_1)); ``` @@ -257,7 +253,7 @@ An alternative to using a `boost::asio::streambuf` is to use a void handle_read(boost::system::error_code); ... beast::streambuf sb; - http::response resp; + http::response_v1 resp; http::read(sock, sb, resp); ``` diff --git a/doc/makeqbk.sh b/doc/makeqbk.sh index 584cb8a9..f215ce4d 100644 --- a/doc/makeqbk.sh +++ b/doc/makeqbk.sh @@ -6,7 +6,7 @@ # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) mkdir -p ../bin/doc/xml -doxygen beast.dox +doxygen source.dox cd ../bin/doc/xml xsltproc combine.xslt index.xml > all.xml cd ../../../doc diff --git a/doc/beast.qbk b/doc/master.qbk similarity index 96% rename from doc/beast.qbk rename to doc/master.qbk index 52cefca8..bfa460b7 100644 --- a/doc/beast.qbk +++ b/doc/master.qbk @@ -106,8 +106,8 @@ int main() // Normal boost::asio setup std::string const host = "boost.org"; boost::asio::io_service ios; - boost::asio::ip::tcp::resolver r(ios); - boost::asio::ip::tcp::socket sock(ios); + boost::asio::ip::tcp::resolver r{ios}; + boost::asio::ip::tcp::socket sock{ios}; boost::asio::connect(sock, r.resolve(boost::asio::ip::tcp::resolver::query{host, "http"})); @@ -142,13 +142,13 @@ int main() // Normal boost::asio setup std::string const host = "echo.websocket.org"; boost::asio::io_service ios; - boost::asio::ip::tcp::resolver r(ios); - boost::asio::ip::tcp::socket sock(ios); + boost::asio::ip::tcp::resolver r{ios}; + boost::asio::ip::tcp::socket sock{ios}; boost::asio::connect(sock, r.resolve(boost::asio::ip::tcp::resolver::query{host, "80"})); // WebSocket connect and send message using beast - beast::websocket::stream ws(sock); + beast::websocket::stream ws{sock}; ws.handshake(host, "/"); ws.write(boost::asio::buffer("Hello, world!")); diff --git a/doc/beast.dox b/doc/source.dox similarity index 100% rename from doc/beast.dox rename to doc/source.dox diff --git a/examples/http_example.cpp b/examples/http_example.cpp index a7869c6c..55d74a82 100644 --- a/examples/http_example.cpp +++ b/examples/http_example.cpp @@ -15,8 +15,8 @@ int main() // Normal boost::asio setup std::string const host = "boost.org"; boost::asio::io_service ios; - boost::asio::ip::tcp::resolver r(ios); - boost::asio::ip::tcp::socket sock(ios); + boost::asio::ip::tcp::resolver r{ios}; + boost::asio::ip::tcp::socket sock{ios}; boost::asio::connect(sock, r.resolve(boost::asio::ip::tcp::resolver::query{host, "http"})); diff --git a/examples/websocket_example.cpp b/examples/websocket_example.cpp index 671af037..e9978d5a 100644 --- a/examples/websocket_example.cpp +++ b/examples/websocket_example.cpp @@ -16,13 +16,13 @@ int main() // Normal boost::asio setup std::string const host = "echo.websocket.org"; boost::asio::io_service ios; - boost::asio::ip::tcp::resolver r(ios); - boost::asio::ip::tcp::socket sock(ios); + boost::asio::ip::tcp::resolver r{ios}; + boost::asio::ip::tcp::socket sock{ios}; boost::asio::connect(sock, r.resolve(boost::asio::ip::tcp::resolver::query{host, "80"})); // WebSocket connect and send message using beast - beast::websocket::stream ws(sock); + beast::websocket::stream ws{sock}; ws.handshake(host, "/"); ws.write(boost::asio::buffer("Hello, world!"));