| 55 | } |
| 56 | |
| 57 | cobalt::main co_main(int argc, char **argv) |
| 58 | { |
| 59 | boost::asio::ssl::context ctx{boost::asio::ssl::context::tls_client}; |
| 60 | auto conn = co_await connect("boost.org", ctx); |
| 61 | printf("connected\n"); |
| 62 | beast::http::request<beast::http::empty_body> req{beast::http::verb::get, "/index.html", 11}; |
| 63 | req.set(beast::http::field::host, "boost.org"); |
| 64 | co_await beast::http::async_write(conn, req, cobalt::use_op); |
| 65 | |
| 66 | // read the response |
| 67 | beast::flat_buffer b; |
| 68 | beast::http::response<beast::http::string_body> response; |
| 69 | co_await beast::http::async_read(conn, b, response, cobalt::use_op); |
| 70 | |
| 71 | // write the response |
| 72 | printf("%s\n", response.body().c_str()); |
| 73 | co_return 0; |
| 74 | } |