yhirose 8 years ago
parent
commit
6d01712fc7
1 changed files with 7 additions and 2 deletions
  1. 7 2
      httplib.h

+ 7 - 2
httplib.h

@@ -509,8 +509,13 @@ bool read_content(Stream& strm, T& x)
     auto len = get_header_value_int(x.headers, "Content-Length", 0);
     auto len = get_header_value_int(x.headers, "Content-Length", 0);
     if (len) {
     if (len) {
         x.body.assign(len, 0);
         x.body.assign(len, 0);
-        if (!strm.read(&x.body[0], x.body.size())) {
-            return false;
+        auto r = 0;
+        while (r < len){
+            auto r_incr = strm.read(&x.body[r], len - r);
+            if (r_incr <= 0) {
+                return false;
+            }
+            r += r_incr;
         }
         }
     }
     }
     return true;
     return true;