From ebdb6f1810a20ac240b5b2192dc2e6532ff149d2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Aug 2016 16:59:13 +0200 Subject: reorganize server-states resetting in http/https MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We keep various information bits about the server around, some only effecting the currently handled file (like sizes) while others should be persistent (like pipeline detections). http used to reset all file-related manually, which is a bit silly if we already have a Reset() method – which does reset all through –, so extending it with a parameter for reuse and calling it from https too (as this was previously resetting by just creating a new state struct – it uses no value of the persistent state-keeping yet as it supports no pipelining). Gbp-Dch: Ignore --- methods/https.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'methods/https.cc') diff --git a/methods/https.cc b/methods/https.cc index 283126f6b..c86f9407e 100644 --- a/methods/https.cc +++ b/methods/https.cc @@ -399,7 +399,10 @@ bool HttpsMethod::Fetch(FetchItem *Itm) // go for it - if the file exists, append on it File = new FileFd(Itm->DestFile, FileFd::WriteAny); - Server = CreateServerState(Itm->Uri); + if (Server == nullptr || Server->Comp(Itm->Uri) == false) + Server = CreateServerState(Itm->Uri); + else + Server->Reset(false); if (Server->InitHashes(Itm->ExpectedHashes) == false) return false; -- cgit v1.2.3 From d94b1d80d8326334d17f6a43061368e783b8e0aa Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Aug 2016 18:24:35 +0200 Subject: don't sent Range requests if we know its not accepted If the server told us in a previous request that it isn't supporting Ranges with bytes via an Accept-Ranges header missing bytes, we don't try to formulate requests using Ranges. --- methods/https.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'methods/https.cc') diff --git a/methods/https.cc b/methods/https.cc index c86f9407e..b2d05136c 100644 --- a/methods/https.cc +++ b/methods/https.cc @@ -382,8 +382,15 @@ bool HttpsMethod::Fetch(FetchItem *Itm) headers = curl_slist_append(headers, "Accept: text/*"); } + // go for it - if the file exists, append on it + File = new FileFd(Itm->DestFile, FileFd::WriteAny); + if (Server == nullptr || Server->Comp(Itm->Uri) == false) + Server = CreateServerState(Itm->Uri); + else + Server->Reset(false); + // if we have the file send an if-range query with a range header - if (stat(Itm->DestFile.c_str(),&SBuf) >= 0 && SBuf.st_size > 0) + if (Server->RangesAllowed && stat(Itm->DestFile.c_str(),&SBuf) >= 0 && SBuf.st_size > 0) { std::string Buf; strprintf(Buf, "Range: bytes=%lli-", (long long) SBuf.st_size); @@ -397,12 +404,6 @@ bool HttpsMethod::Fetch(FetchItem *Itm) curl_easy_setopt(curl, CURLOPT_TIMEVALUE, Itm->LastModified); } - // go for it - if the file exists, append on it - File = new FileFd(Itm->DestFile, FileFd::WriteAny); - if (Server == nullptr || Server->Comp(Itm->Uri) == false) - Server = CreateServerState(Itm->Uri); - else - Server->Reset(false); if (Server->InitHashes(Itm->ExpectedHashes) == false) return false; -- cgit v1.2.3