summaryrefslogtreecommitdiff
path: root/methods/https.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2015-05-22 14:17:04 +0200
committerMichael Vogt <mvo@ubuntu.com>2015-05-22 14:17:04 +0200
commit68be2fbb252a71303046e2ca7866cd659a91b585 (patch)
treed9ad50c5fa43943c409fed2e7e8d476f4603fd42 /methods/https.cc
parente29a7a394cfd41e8bad81535e0a8c07654f34bf6 (diff)
parent15901516326737a67f2a9af26cd7e434162de019 (diff)
Merge remote-tracking branch 'upstream/debian/sid' into debian/sid
Diffstat (limited to 'methods/https.cc')
-rw-r--r--methods/https.cc21
1 files changed, 17 insertions, 4 deletions
diff --git a/methods/https.cc b/methods/https.cc
index 0499af0c5..3a5981b58 100644
--- a/methods/https.cc
+++ b/methods/https.cc
@@ -59,6 +59,9 @@ HttpsMethod::parse_header(void *buffer, size_t size, size_t nmemb, void *userp)
{
me->Server->Result = 200;
me->Server->StartPos = me->Server->Size;
+ // the actual size is not important for https as curl will deal with it
+ // by itself and e.g. doesn't bother us with transport-encoding…
+ me->Server->JunkSize = std::numeric_limits<unsigned long long>::max();
}
else
me->Server->StartPos = 0;
@@ -76,18 +79,27 @@ size_t
HttpsMethod::write_data(void *buffer, size_t size, size_t nmemb, void *userp)
{
HttpsMethod *me = (HttpsMethod *)userp;
+ size_t buffer_size = size * nmemb;
+ // we don't need to count the junk here, just drop anything we get as
+ // we don't always know how long it would be, e.g. in chunked encoding.
+ if (me->Server->JunkSize != 0)
+ return buffer_size;
- if (me->Res.Size == 0)
+ if (me->ReceivedData == false)
+ {
me->URIStart(me->Res);
- if(me->File->Write(buffer, size*nmemb) != true)
+ me->ReceivedData = true;
+ }
+
+ if(me->File->Write(buffer, buffer_size) != true)
return false;
- return size*nmemb;
+ 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) {
@@ -171,6 +183,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
char curl_errorstr[CURL_ERROR_SIZE];
URI Uri = Itm->Uri;
string remotehost = Uri.Host;
+ ReceivedData = false;
// TODO:
// - http::Pipeline-Depth