52 using boost::asio::ip::tcp;
54 io_service io_service;
57 tcp::resolver resolver(io_service);
59 tcp::resolver::iterator endpoint_iterator = resolver.resolve(
query);
60 tcp::resolver::iterator end;
63 tcp::socket socket(io_service);
64 boost::system::error_code error = boost::asio::error::host_not_found;
65 while (error && endpoint_iterator != end)
68 socket.connect(*endpoint_iterator++, error);
71 boost::asio::streambuf request;
72 std::ostream request_stream(&request);
74 request_stream <<
"GET " << getCommand <<
" HTTP/1.0\r\n";
75 request_stream <<
"Host: " << serverName <<
':' << port <<
"\r\n";
76 request_stream <<
"Accept: */*\r\n";
77 request_stream <<
"Connection: close\r\n\r\n";
80 boost::asio::write(socket, request);
83 boost::asio::streambuf response;
84 boost::asio::read_until(socket, response,
"\r\n");
87 std::istream response_stream(&response);
88 std::string http_version;
89 response_stream >> http_version;
90 unsigned int status_code;
91 response_stream >> status_code;
92 std::string status_message;
93 std::getline(response_stream, status_message);
96 boost::asio::read_until(socket, response,
"\r\n\r\n");
100 while (std::getline(response_stream, header) && header !=
"\r")
104 if (response.size() > 0)
108 while (boost::asio::read(socket, response, boost::asio::transfer_at_least(1), error))
char * query(struct soap *soap)
Definition: httpget.cpp:244