// Constructor
client(boost::asio::io_service& io_service,
const std::string& server, const std::string& path)
: resolver_(io_service),
socket_(io_service)
{
// Form the request. We specify the "Connection: close" header so that the
// server will close the socket after transmitting the response. This will
// allow us to treat all data up until the EOF as the content.
std::ostream request_stream(&request_);
request_stream << "POST " << path << " HTTP/1.0\r\n";
request_stream << "Host: " << server << "\r\n";
request_stream << "Content-Type: application/x-www-form-urlencoded\r\n";
request_stream << "Authorization: OAuth oauth_version=\"1.0\", oauth_signature_method=\"PLAINTEXT\", "
<<"oauth_consumer_key=\"<key>\", "
<<"oauth_signature=\"<secret>&\"\r\n";
request_stream << "Accept: */*\r\n";
request_stream << "Connection: close\r\n\r\n";
// Start an asynchronous resolve to translate the server and service names
// into a list of endpoints.
tcp::resolver::query query(server, "https");
resolver_.async_resolve(query,
boost::bind(&client::handle_resolve, this,
boost::asio::placeholders::error,
boost::asio::placeholders::iterator));
}
In any case, this isn't an asio issue, it's a protocol issue: if you netcat the same strings to the same port, you should receive the same error code (which one was it?).
If you really mean to use https, take a look at the example at http://www.boost.org/doc/libs/release/doc/html/boost_asio/example/cpp03/ssl/client.cpp A higher-level library such as cpp-netlib would make this much easier.