Skip to content

Commit 6cdd349

Browse files
committed
Fix #1788
1 parent 9c91b6f commit 6cdd349

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

httplib.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7720,6 +7720,14 @@ inline bool ClientImpl::process_request(Stream &strm, Request &req,
77207720
return ret;
77217721
};
77227722

7723+
if (res.has_header("Content-Length")) {
7724+
if (!req.content_receiver) {
7725+
auto len = std::min<size_t>(res.get_header_value_u64("Content-Length"),
7726+
res.body.max_size());
7727+
if (len > 0) { res.body.reserve(len); }
7728+
}
7729+
}
7730+
77237731
int dummy_status;
77247732
if (!detail::read_content(strm, res, (std::numeric_limits<size_t>::max)(),
77257733
dummy_status, std::move(progress), std::move(out),

0 commit comments

Comments
 (0)