From 6caf4b0d0bcf7b2072da2e5405fcec0a30283acc Mon Sep 17 00:00:00 2001
From: Seva <seva@binarytrails.net>
Date: Fri, 18 Oct 2019 11:06:28 -0400
Subject: [PATCH] http: ensure no data is lost in read_bytes

---
 src/http.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/http.cpp b/src/http.cpp
index 57127c89..4c2bb8fc 100644
--- a/src/http.cpp
+++ b/src/http.cpp
@@ -210,9 +210,12 @@ Connection::data()
 std::string
 Connection::read_bytes(const size_t bytes)
 {
-    std::ostringstream str_s;
-    str_s << &read_buf_;
-    return str_s.str().substr(0, bytes);
+    std::string content;
+    std::istream is(&read_buf_);
+    content.resize(bytes);
+    auto rb = is.readsome(&content[0], bytes);
+    content.resize(rb);
+    return content;
 }
 
 std::string
-- 
GitLab