boost::asio, synchronous HTTP read on sslstream
I have a problem reading on a sslstream. If the content-length is
specified it works fine, I read exactly the given length and have a
complet answer. If I didn't get a content-length header from the server
I use an algorithm like this:
// ... initializations ...
// ... read HTTP headers ...
// (get no content-length here)
// read the HTTP body
while ((n = asio::read(*m_pSslStream, sb,
asio::transfer_exactly(1024), error)) > 0)
// ... handle contents ...
This should read 1k-blocks until there are no more bytes in the stream.
The last call to the read-function should return less than 1024 bytes
and an error code. Indeed this happens, exactly as specified, but the
last call to the read-function doesn't return before a long timeout is
reached, about one minute or more. What's the reason for this?
I tried also other things: transfer_at_least() or transfer_all(), also
the read_some-method of the sslstream class. All show exactly the same
What can I do to avoid this timeout at the end? Is this related to SSL?
I can't remember that I had problems with this on non-SSL streams.