Skip to content

Commit 992f3dc

Browse files
committed
Code cleanup
1 parent 402d47e commit 992f3dc

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

httplib.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4032,17 +4032,16 @@ inline bool Client::process_request(Stream &strm, const Request &req,
40324032

40334033
// Body
40344034
if (req.method != "HEAD" && req.method != "CONNECT") {
4035-
ContentReceiver out = [&](const char *buf, size_t n) {
4036-
if (res.body.size() + n > res.body.max_size()) { return false; }
4037-
res.body.append(buf, n);
4038-
return true;
4039-
};
4040-
4041-
if (req.content_receiver) {
4042-
out = [&](const char *buf, size_t n) {
4043-
return req.content_receiver(buf, n);
4044-
};
4045-
}
4035+
auto out =
4036+
req.content_receiver
4037+
? static_cast<ContentReceiver>([&](const char *buf, size_t n) {
4038+
return req.content_receiver(buf, n);
4039+
})
4040+
: static_cast<ContentReceiver>([&](const char *buf, size_t n) {
4041+
if (res.body.size() + n > res.body.max_size()) { return false; }
4042+
res.body.append(buf, n);
4043+
return true;
4044+
});
40464045

40474046
int dummy_status;
40484047
if (!detail::read_content(strm, res, (std::numeric_limits<size_t>::max)(),

0 commit comments

Comments
 (0)