From 5dd9bacff0c96c57385fe7051f781542a66fced3 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Mon, 20 Jun 2016 10:53:31 -0400 Subject: [PATCH] Simplify HTTP crawler example --- examples/http_crawl.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/http_crawl.cpp b/examples/http_crawl.cpp index b995c201..9948851f 100644 --- a/examples/http_crawl.cpp +++ b/examples/http_crawl.cpp @@ -5,9 +5,10 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include "http_stream.hpp" #include "urls_large_data.hpp" +#include +#include #include #include @@ -31,9 +32,9 @@ int main(int, char const*[]) ip::tcp::resolver r(ios); auto it = r.resolve( ip::tcp::resolver::query{host, "http"}); - stream hs(ios); - connect(hs.lowest_layer(), it); - auto ep = hs.lowest_layer().remote_endpoint(); + ip::tcp::socket sock(ios); + connect(sock, it); + auto ep = sock.remote_endpoint(); request_v1 req; req.method = "GET"; req.url = "/"; @@ -42,10 +43,11 @@ int main(int, char const*[]) std::string(":") + std::to_string(ep.port())); req.headers.insert("User-Agent", "beast/http"); prepare(req); - hs.write(req); - response_v1 resp; - hs.read(resp); - std::cout << resp; + write(sock, req); + response_v1 res; + streambuf sb; + beast::http::read(sock, sb, res); + std::cout << res; } catch(boost::system::system_error const& ec) {