Refactor HTTP serialization and parsing (API Change):

fix #404

Parsing and serialization interfaces have been fine tuned and unified.

For parsing these stream operations are defined:

* read
* read_header
* read_some
* async_read
* async_read_header
* async_read_some

For serialization these stream operations are defined:

* write
* write_header
* write_some
* async_write
* async_write_header
* async_write_some
This commit is contained in:
Vinnie Falco
2017-05-31 08:01:55 -07:00
parent b76eb2864e
commit 02d5aedc29
44 changed files with 3655 additions and 3250 deletions

View File

@@ -188,6 +188,7 @@ int main()
Example HTTP program:
```C++
#include <beast/core.hpp>
#include <beast/http.hpp>
#include <boost/asio.hpp>
#include <boost/lexical_cast.hpp>
@@ -197,7 +198,7 @@ Example HTTP program:
int main()
{
// Normal boost::asio setup
std::string const host = "boost.org";
std::string const host = "www.example.com";
boost::asio::io_service ios;
boost::asio::ip::tcp::resolver r{ios};
boost::asio::ip::tcp::socket sock{ios};
@@ -206,7 +207,7 @@ int main()
// Send HTTP request using beast
beast::http::request<beast::http::string_body> req;
req.method("GET");
req.method(beast::http::verb::get);
req.target("/");
req.version = 11;
req.fields.replace("Host", host + ":" +
@@ -216,10 +217,10 @@ int main()
beast::http::write(sock, req);
// Receive and print HTTP response using beast
beast::streambuf sb;
beast::http::response<beast::http::dynamic_body> resp;
beast::http::read(sock, sb, resp);
std::cout << resp;
beast::flat_buffer b;
beast::http::response<beast::http::dynamic_body> res;
beast::http::read(sock, b, res);
std::cout << res << std::endl;
}
```