
I'm playing with the following SSL client example against an https site: http://www.boost.org/doc/libs/1_36_0/doc/html/boost_asio/example/ssl/client.... I replaced std::cout << "Enter message: " with the part of the URL corresponding to an HTTP GET request, and changed the handle_read() to void handle_read(const boost::system::error_code& error, size_t bytes_transferred) { if (!error) { std::cout << "Reply: "; std::cout.write(reply_, bytes_transferred); std::cout << "\n"; boost::asio::async_read(socket_, boost::asio::buffer(reply_, bytes_transferred), boost::bind(&client::handle_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); } else { std::cout << "Read failed: " << error << "\n"; } } so that it goes back to read more data. I'm able to get more than 20k data in response, but unable to reach the end of the data stream as the browser can. What could be a good reason for this behavior? Thanks, Greg

Gregory Dai wrote:
I'm playing with the following SSL client example against an https site: [...] I'm able to get more than 20k data in response, but unable to reach the end of the data stream as the browser can.
To know where the end of data is an HTTP keep-alive connection, you have to use the Content-Length header or the chunked transfer encoding.

Thank you, Mathias, for replying. I figured it out. The server finished sending all data and shut down its TCP endpoint, for which the last async_read() call threw an exception (of ESHUTDOWN), which aborted my logic flow. I was thrilled that it finally worked. I was also able to get a synchronous version to work. Use read() instead of async_read(), and also an asio::streambuf to collect everything in the response in one read() call. Cheers, Greg On Thu, Oct 23, 2008 at 3:18 AM, Mathias Gaunard < mathias.gaunard@ens-lyon.org> wrote:
Gregory Dai wrote:
I'm playing with the following SSL client example against an https site:
[...]
I'm able to get more than 20k data in response, but unable to reach the end of the data stream as the browser can.
To know where the end of data is an HTTP keep-alive connection, you have to use the Content-Length header or the chunked transfer encoding.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Gregory Dai
-
Mathias Gaunard