Closed
Description
Hi,
I was running into an issue with cpp-httplib on the inline method read_content_without_length
. When a POST is made, the HTTP server returns a relative large body, more than 40K bytes. The response header does not contain "Content-Length", read_content_without_length
is invoked and the httplib::Client
eventually returns with error READ. This is because read_content_without_length
returns false.
Here is its body
inline bool read_content_without_length(Stream &strm,
ContentReceiverWithProgress out) {
char buf[CPPHTTPLIB_RECV_BUFSIZ];
uint64_t r = 0;
for (;;) {
auto n = strm.read(buf, CPPHTTPLIB_RECV_BUFSIZ);
if (n <= 0) { return false; }
if (!out(buf, static_cast<size_t>(n), r, 0)) { return false; }
r += static_cast<uint64_t>(n);
}
return true;
}
It appears this method will always return false? I assume 0 will be returned when the stream reaches its end. In such case, should the for loop be broken instead of returning false?
Thanks