@@ -5807,22 +5807,22 @@ inline bool ClientImpl::process_request(Stream &strm, Request &req,
5807
5807
return false ;
5808
5808
}
5809
5809
5810
- if (req.response_handler ) {
5811
- if (!req.response_handler (res)) {
5812
- error = Error::Canceled;
5813
- return false ;
5814
- }
5815
- }
5816
-
5817
5810
// Body
5818
5811
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
+
5819
5821
auto out =
5820
5822
req.content_receiver
5821
5823
? static_cast <ContentReceiverWithProgress>(
5822
5824
[&](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 ; }
5826
5826
auto ret = req.content_receiver (buf, n, off, len);
5827
5827
if (!ret) { error = Error::Canceled; }
5828
5828
return ret;
@@ -5838,7 +5838,7 @@ inline bool ClientImpl::process_request(Stream &strm, Request &req,
5838
5838
});
5839
5839
5840
5840
auto progress = [&](uint64_t current, uint64_t total) {
5841
- if (!req.progress ) { return true ; }
5841
+ if (!req.progress || redirect ) { return true ; }
5842
5842
auto ret = req.progress (current, total);
5843
5843
if (!ret) { error = Error::Canceled; }
5844
5844
return ret;
0 commit comments