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

Method client

example/cpp11/http/client/async_client.cpp:23–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21{
22public:
23 client(boost::asio::io_context& io_context,
24 const std::string& server, const std::string& path)
25 : resolver_(io_context),
26 socket_(io_context)
27 {
28 // Form the request. We specify the "Connection: close" header so that the
29 // server will close the socket after transmitting the response. This will
30 // allow us to treat all data up until the EOF as the content.
31 std::ostream request_stream(&request_);
32 request_stream << "GET " << path << " HTTP/1.0\r\n";
33 request_stream << "Host: " << server << "\r\n";
34 request_stream << "Accept: */*\r\n";
35 request_stream << "Connection: close\r\n\r\n";
36
37 // Start an asynchronous resolve to translate the server and service names
38 // into a list of endpoints.
39 resolver_.async_resolve(server, "http",
40 std::bind(&client::handle_resolve, this,
41 boost::asio::placeholders::error,
42 boost::asio::placeholders::results));
43 }
44
45private:
46 void handle_resolve(const boost::system::error_code& err,

Callers

nothing calls this directly

Calls 2

bindFunction · 0.50
async_resolveMethod · 0.45

Tested by

no test coverage detected