Skip to content

Commit faa5f1d

Browse files
committed
Additional changes for #889
1 parent 9d3365d commit faa5f1d

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

httplib.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5807,22 +5807,22 @@ inline bool ClientImpl::process_request(Stream &strm, Request &req,
58075807
return false;
58085808
}
58095809

5810-
if (req.response_handler) {
5811-
if (!req.response_handler(res)) {
5812-
error = Error::Canceled;
5813-
return false;
5814-
}
5815-
}
5816-
58175810
// Body
58185811
if ((res.status != 204) && req.method != "HEAD" && req.method != "CONNECT") {
5812+
auto redirect = 300 < res.status && res.status < 400 && follow_location_;
5813+
5814+
if (req.response_handler && !redirect) {
5815+
if (!req.response_handler(res)) {
5816+
error = Error::Canceled;
5817+
return false;
5818+
}
5819+
}
5820+
58195821
auto out =
58205822
req.content_receiver
58215823
? static_cast<ContentReceiverWithProgress>(
58225824
[&](const char *buf, size_t n, uint64_t off, uint64_t len) {
5823-
if (300 < res.status && res.status < 400 && follow_location_) {
5824-
return true;
5825-
}
5825+
if (redirect) { return true; }
58265826
auto ret = req.content_receiver(buf, n, off, len);
58275827
if (!ret) { error = Error::Canceled; }
58285828
return ret;
@@ -5838,7 +5838,7 @@ inline bool ClientImpl::process_request(Stream &strm, Request &req,
58385838
});
58395839

58405840
auto progress = [&](uint64_t current, uint64_t total) {
5841-
if (!req.progress) { return true; }
5841+
if (!req.progress || redirect) { return true; }
58425842
auto ret = req.progress(current, total);
58435843
if (!ret) { error = Error::Canceled; }
58445844
return ret;

0 commit comments

Comments
 (0)