MCPcopy Create free account
hub / github.com/boostorg/asio / do_read

Method do_read

example/cpp11/http/server2/connection.cpp:30–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30void connection::do_read()
31{
32 auto self(shared_from_this());
33 socket_.async_read_some(boost::asio::buffer(buffer_),
34 [this, self](boost::system::error_code ec, std::size_t bytes_transferred)
35 {
36 if (!ec)
37 {
38 request_parser::result_type result;
39 std::tie(result, std::ignore) = request_parser_.parse(
40 request_, buffer_.data(), buffer_.data() + bytes_transferred);
41
42 if (result == request_parser::good)
43 {
44 request_handler_.handle_request(request_, reply_);
45 do_write();
46 }
47 else if (result == request_parser::bad)
48 {
49 reply_ = reply::stock_reply(reply::bad_request);
50 do_write();
51 }
52 else
53 {
54 do_read();
55 }
56 }
57
58 // If an error occurs then no new asynchronous operations are
59 // started. This means that all shared_ptr references to the
60 // connection object will disappear and the object will be
61 // destroyed automatically after this handler returns. The
62 // connection class's destructor closes the socket.
63 });
64}
65
66void connection::do_write()
67{

Callers

nothing calls this directly

Calls 6

bufferFunction · 0.85
do_readFunction · 0.85
async_read_someMethod · 0.45
parseMethod · 0.45
dataMethod · 0.45
handle_requestMethod · 0.45

Tested by

no test coverage detected