|
Boost Users : |
Subject: Re: [Boost-users] asio HTTP client example always returns error 400
From: G S (stokestack_at_[hidden])
Date: 2010-08-25 02:56:55
On Tue, Aug 24, 2010 at 3:38 PM, G S <stokestack_at_[hidden]> wrote:
> I copied the boost::asio HTTP client example code:
> http://live.boost.org/doc/libs/1_39_0/doc/html/boost_asio/example/http/client/sync_client.cpp
>
> and just replaced the argv stuff with a hard-coded domain name and
> "index.html". It appears to make the socket connection OK, but the
> response to the request is 400 ("bad request").
OK, it turns out that it doesn't matter what I put as the host. This
doesn't return an error:
boost::asio::io_service io_service;
// Get a list of endpoints corresponding to the server name.
tcp::resolver resolver(io_service);
tcp::resolver::query query("ksjfkdsjkfjds.com", "http");
tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
tcp::resolver::iterator end;
// Try each endpoint until we successfully establish a connection.
tcp::socket socket(io_service);
boost::system::error_code error = boost::asio::error::host_not_found;
while (error && endpoint_iterator != end)
{
socket.close();
socket.connect(*endpoint_iterator++, error);
}
What gives?
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net