MCPcopy Create free account
hub / github.com/boostorg/beast / handle_session

Function handle_session

example/doc/ssl/server.cpp:40–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40net::awaitable<void>
41handle_session(ssl::stream<net::ip::tcp::socket> stream)
42{
43 // Perform the SSL handshake
44 co_await stream.async_handshake(ssl::stream_base::server);
45
46 // Read and discard a request
47 beast::flat_buffer buf;
48 http::request<http::empty_body> req;
49 co_await http::async_read(stream, buf, req);
50
51 // Write the response
52 http::response<http::string_body> res;
53 res.body() = "Hello!";
54 co_await http::async_write(stream, res);
55
56 // Gracefully shutdown the SSL stream
57 auto [ec] = co_await stream.async_shutdown(net::as_tuple);
58 if(ec && ec != ssl::error::stream_truncated)
59 throw boost::system::system_error(ec);
60}
61
62net::awaitable<void>
63acceptor(ssl::context& ctx)

Callers 1

acceptorFunction · 0.85

Calls 4

bodyMethod · 0.80
async_readFunction · 0.50
async_writeFunction · 0.50
async_handshakeMethod · 0.45

Tested by

no test coverage detected