Additional changes for #889
This commit is contained in:
parent
9d3365df54
commit
faa5f1d802
14
httplib.h
14
httplib.h
@ -5807,22 +5807,22 @@ inline bool ClientImpl::process_request(Stream &strm, Request &req,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.response_handler) {
|
// Body
|
||||||
|
if ((res.status != 204) && req.method != "HEAD" && req.method != "CONNECT") {
|
||||||
|
auto redirect = 300 < res.status && res.status < 400 && follow_location_;
|
||||||
|
|
||||||
|
if (req.response_handler && !redirect) {
|
||||||
if (!req.response_handler(res)) {
|
if (!req.response_handler(res)) {
|
||||||
error = Error::Canceled;
|
error = Error::Canceled;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Body
|
|
||||||
if ((res.status != 204) && req.method != "HEAD" && req.method != "CONNECT") {
|
|
||||||
auto out =
|
auto out =
|
||||||
req.content_receiver
|
req.content_receiver
|
||||||
? static_cast<ContentReceiverWithProgress>(
|
? static_cast<ContentReceiverWithProgress>(
|
||||||
[&](const char *buf, size_t n, uint64_t off, uint64_t len) {
|
[&](const char *buf, size_t n, uint64_t off, uint64_t len) {
|
||||||
if (300 < res.status && res.status < 400 && follow_location_) {
|
if (redirect) { return true; }
|
||||||
return true;
|
|
||||||
}
|
|
||||||
auto ret = req.content_receiver(buf, n, off, len);
|
auto ret = req.content_receiver(buf, n, off, len);
|
||||||
if (!ret) { error = Error::Canceled; }
|
if (!ret) { error = Error::Canceled; }
|
||||||
return ret;
|
return ret;
|
||||||
@ -5838,7 +5838,7 @@ inline bool ClientImpl::process_request(Stream &strm, Request &req,
|
|||||||
});
|
});
|
||||||
|
|
||||||
auto progress = [&](uint64_t current, uint64_t total) {
|
auto progress = [&](uint64_t current, uint64_t total) {
|
||||||
if (!req.progress) { return true; }
|
if (!req.progress || redirect) { return true; }
|
||||||
auto ret = req.progress(current, total);
|
auto ret = req.progress(current, total);
|
||||||
if (!ret) { error = Error::Canceled; }
|
if (!ret) { error = Error::Canceled; }
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user