mirror of
https://github.com/yhirose/cpp-httplib
synced 2024-11-21 14:29:10 -07:00
Additional changes for #889
This commit is contained in:
parent
9d3365df54
commit
faa5f1d802
1 changed files with 11 additions and 11 deletions
14
httplib.h
14
httplib.h
|
@ -5807,22 +5807,22 @@ inline bool ClientImpl::process_request(Stream &strm, Request &req,
|
|||
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)) {
|
||||
error = Error::Canceled;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Body
|
||||
if ((res.status != 204) && req.method != "HEAD" && req.method != "CONNECT") {
|
||||
auto out =
|
||||
req.content_receiver
|
||||
? static_cast<ContentReceiverWithProgress>(
|
||||
[&](const char *buf, size_t n, uint64_t off, uint64_t len) {
|
||||
if (300 < res.status && res.status < 400 && follow_location_) {
|
||||
return true;
|
||||
}
|
||||
if (redirect) { return true; }
|
||||
auto ret = req.content_receiver(buf, n, off, len);
|
||||
if (!ret) { error = Error::Canceled; }
|
||||
return ret;
|
||||
|
@ -5838,7 +5838,7 @@ inline bool ClientImpl::process_request(Stream &strm, Request &req,
|
|||
});
|
||||
|
||||
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);
|
||||
if (!ret) { error = Error::Canceled; }
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue