Boost logo

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:
> 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("", "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.connect(*endpoint_iterator++, error);

What gives?

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at