diff options
Diffstat (limited to 'methods/https.cc')
-rw-r--r-- | methods/https.cc | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/methods/https.cc b/methods/https.cc index 3a5981b58..37a8ff5fd 100644 --- a/methods/https.cc +++ b/methods/https.cc @@ -37,6 +37,16 @@ /*}}}*/ using namespace std; +bool HttpsMethod::Configuration(std::string Message) +{ + if (pkgAcqMethod::Configuration(Message) == false) + return false; + + DropPrivsOrDie(); + + return true; +} + size_t HttpsMethod::parse_header(void *buffer, size_t size, size_t nmemb, void *userp) { @@ -85,21 +95,33 @@ HttpsMethod::write_data(void *buffer, size_t size, size_t nmemb, void *userp) if (me->Server->JunkSize != 0) return buffer_size; - if (me->ReceivedData == false) + if (me->Server->ReceivedData == false) { me->URIStart(me->Res); - me->ReceivedData = true; + me->Server->ReceivedData = true; } if(me->File->Write(buffer, buffer_size) != true) - return false; + return 0; + + if(me->Queue->MaximumSize > 0) + { + unsigned long long const TotalWritten = me->File->Tell(); + if (TotalWritten > me->Queue->MaximumSize) + { + me->SetFailReason("MaximumSizeExceeded"); + _error->Error("Writing more data than expected (%llu > %llu)", + TotalWritten, me->Queue->MaximumSize); + return 0; + } + } return buffer_size; } int HttpsMethod::progress_callback(void *clientp, double dltotal, double /*dlnow*/, - double /*ultotal*/, double /*ulnow*/) + double /*ultotal*/, double /*ulnow*/) { HttpsMethod *me = (HttpsMethod *)clientp; if(dltotal > 0 && me->Res.Size == 0) { @@ -112,6 +134,7 @@ HttpsMethod::progress_callback(void *clientp, double dltotal, double /*dlnow*/, HttpsServerState::HttpsServerState(URI Srv,HttpsMethod * /*Owner*/) : ServerState(Srv, NULL) { TimeOut = _config->FindI("Acquire::https::Timeout",TimeOut); + ReceivedData = false; Reset(); } /*}}}*/ @@ -179,11 +202,10 @@ void HttpsMethod::SetupProxy() /*{{{*/ bool HttpsMethod::Fetch(FetchItem *Itm) { struct stat SBuf; - struct curl_slist *headers=NULL; + struct curl_slist *headers=NULL; char curl_errorstr[CURL_ERROR_SIZE]; URI Uri = Itm->Uri; string remotehost = Uri.Host; - ReceivedData = false; // TODO: // - http::Pipeline-Depth |