diff options
author | David Kalnischkies <david@kalnischkies.de> | 2015-03-09 01:34:10 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2015-03-16 17:59:31 +0100 |
commit | d61960d9244340956a27f4ca46aecd15cc75e18b (patch) | |
tree | c8f7cb33e08c84bcf06fbff39647dc03bc103afb /methods | |
parent | b0be0e09cfbbcb033eb0b92eaf17ac31a6b9f423 (diff) | |
parent | 1a0619ac765cc0b2f4906c96c1a4d7f510569a3f (diff) |
merge debian/sid into debian/experimental
Diffstat (limited to 'methods')
-rw-r--r-- | methods/https.cc | 28 | ||||
-rw-r--r-- | methods/https.h | 11 | ||||
-rw-r--r-- | methods/server.cc | 2 |
3 files changed, 26 insertions, 15 deletions
diff --git a/methods/https.cc b/methods/https.cc index 23b3a10d4..37a8ff5fd 100644 --- a/methods/https.cc +++ b/methods/https.cc @@ -95,24 +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->Res.Size == 0) + if (me->Server->ReceivedData == false) + { me->URIStart(me->Res); + me->Server->ReceivedData = true; + } + if(me->File->Write(buffer, buffer_size) != true) - return false; + return 0; - if(me->Queue->MaximumSize > 0 && me->File->Tell() > me->Queue->MaximumSize) + if(me->Queue->MaximumSize > 0) { - me->SetFailReason("MaximumSizeExceeded"); - _error->Error("Writing more data than expected (%llu > %llu)", - me->TotalWritten, me->Queue->MaximumSize); - return 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) { @@ -125,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(); } /*}}}*/ @@ -192,7 +202,7 @@ 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; diff --git a/methods/https.h b/methods/https.h index 9df18e83a..6917a6ff6 100644 --- a/methods/https.h +++ b/methods/https.h @@ -50,6 +50,8 @@ class HttpsServerState : public ServerState HttpsServerState(URI Srv, HttpsMethod *Owner); virtual ~HttpsServerState() {Close();}; + + bool ReceivedData; }; class HttpsMethod : public pkgAcqMethod @@ -62,18 +64,17 @@ class HttpsMethod : public pkgAcqMethod static size_t parse_header(void *buffer, size_t size, size_t nmemb, void *userp); static size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp); - static int progress_callback(void *clientp, double dltotal, double dlnow, - double ultotal, double ulnow); + static int progress_callback(void *clientp, double dltotal, double dlnow, + double ultotal, double ulnow); void SetupProxy(); CURL *curl; FetchResult Res; HttpsServerState *Server; - unsigned long long TotalWritten; public: FileFd *File; - - HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig), Server(NULL), TotalWritten(0), File(NULL) + + HttpsMethod() : pkgAcqMethod("1.2",Pipeline | SendConfig), Server(NULL), File(NULL) { curl = curl_easy_init(); }; diff --git a/methods/server.cc b/methods/server.cc index 9b3d39cf2..c17f27f73 100644 --- a/methods/server.cc +++ b/methods/server.cc @@ -129,7 +129,7 @@ bool ServerState::HeaderLine(string Line) if (elements == 3) { Code[0] = '\0'; - if (Owner->Debug == true) + if (Owner != NULL && Owner->Debug == true) clog << "HTTP server doesn't give Reason-Phrase for " << Result << std::endl; } else if (elements != 4) |