From: David Kalnischkies Date: Wed, 15 Jun 2016 10:45:07 +0000 (+0200) Subject: http: don't hang on redirect with length + connection close X-Git-Tag: 1.3_exp3~16 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/99968cf75b46210bded1662d34c4c2b0ef07be04 http: don't hang on redirect with length + connection close Most servers who close the connection do not send a content-length as this is redundant information usually, but some might and while testing with our server and with 'aptwebserver::response-header::Connection' set to 'close' I noticed that http hangs after a redirect in such cases, so if we have the information, just use it instead of discarding it. --- diff --git a/methods/http.cc b/methods/http.cc index b861e61ee..fc54ece3a 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -441,12 +441,12 @@ bool HttpServerState::RunData(FileFd * const File) { /* Closes encoding is used when the server did not specify a size, the loss of the connection means we are done */ - if (Persistent == false) - In.Limit(-1); - else if (JunkSize != 0) + if (JunkSize != 0) In.Limit(JunkSize); - else + else if (DownloadSize != 0) In.Limit(DownloadSize); + else if (Persistent == false) + In.Limit(-1); // Just transfer the whole block. do