Hi Casablanca,
I am trying to read body stream from a http_response, occasionally I read out less data than reported by "content length". Here is my code:
size_t contentLen = response.headers().content_length();
rawptr_buffer<char> rbuf(buffer, bufSize);
size_t bytesRead = response.body().read_to_end(rbuf).get();
Most of the time, bytesRead == contenLen. sometimes: bytesRead < contentLen. I also tried following way:
size_t contentLen = response.headers().content_length();
response.content_ready.wait();
size_t bytesRead = response.body().streambuf().scopy(buffer, contentLen);
The issue remains. It seems bytesRead == http_msg::m_data_available.
My question is:
1. is it expected that bytesRead < contenLen?
2. What is the correct way to read out all contents?
Thanks in advance for your help.
Vincent
I am trying to read body stream from a http_response, occasionally I read out less data than reported by "content length". Here is my code:
size_t contentLen = response.headers().content_length();
rawptr_buffer<char> rbuf(buffer, bufSize);
size_t bytesRead = response.body().read_to_end(rbuf).get();
Most of the time, bytesRead == contenLen. sometimes: bytesRead < contentLen. I also tried following way:
size_t contentLen = response.headers().content_length();
response.content_ready.wait();
size_t bytesRead = response.body().streambuf().scopy(buffer, contentLen);
The issue remains. It seems bytesRead == http_msg::m_data_available.
My question is:
1. is it expected that bytesRead < contenLen?
2. What is the correct way to read out all contents?
Thanks in advance for your help.
Vincent