+ if (success != CURLE_OK)
+ {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wswitch"
+ switch (success)
+ {
+ case CURLE_COULDNT_RESOLVE_PROXY:
+ case CURLE_COULDNT_RESOLVE_HOST:
+ SetFailReason("ResolveFailure");
+ break;
+ case CURLE_COULDNT_CONNECT:
+ SetFailReason("ConnectionRefused");
+ break;
+ case CURLE_OPERATION_TIMEDOUT:
+ SetFailReason("Timeout");
+ break;
+ }
+#pragma GCC diagnostic pop
+ // only take curls technical errors if we haven't our own
+ // (e.g. for the maximum size limit we have and curls can be confusing)
+ if (_error->PendingError() == false)
+ _error->Error("%s", curl_errorstr);
+ else
+ _error->Warning("curl: %s", curl_errorstr);
+ return false;
+ }
+
+ // server says file not modified
+ if (Server->Result == 304 || curl_condition_unmet == 1)
+ {
+ RemoveFile("https", File->Name());
+ Res.IMSHit = true;
+ Res.LastModified = Itm->LastModified;
+ Res.Size = 0;
+ URIDone(Res);
+ return true;
+ }
+ Res.IMSHit = false;
+
+ if (Server->Result != 200 && // OK
+ Server->Result != 206 && // Partial
+ Server->Result != 416) // invalid Range
+ {
+ char err[255];
+ snprintf(err, sizeof(err) - 1, "HttpError%i", Server->Result);
+ SetFailReason(err);
+ _error->Error("%i %s", Server->Result, Server->Code);
+ // unlink, no need keep 401/404 page content in partial/
+ RemoveFile("https", File->Name());
+ return false;
+ }
+
+ // invalid range-request
+ if (Server->Result == 416)
+ {
+ RemoveFile("https", File->Name());
+ delete File;
+ Redirect(Itm->Uri);