summaryrefslogtreecommitdiff
path: root/methods/https.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-11-29 17:59:52 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-12-09 01:13:48 +0100
commited793a19ec00b83254029509bc516e3ba911c75a (patch)
tree7ed00330d6df58250cc53cd6ee47717f117ab8d0 /methods/https.cc
parentecb777ddb4d13bb7a18bbf2ebb8e2c810dcaeb72 (diff)
dispose http(s) 416 error page as non-content
Real webservers (like apache) actually send an error page with a 416 response, but our client didn't expect it leaving the page on the socket to be parsed as response for the next request (http) or as file content (https), which isn't what we want at all… Symptom is a "Bad header line" as html usually doesn't parse that well to an http-header. This manifests itself e.g. if we have a complete file (or larger) in partial/ which isn't discarded by If-Range as the server doesn't support it (or it is just newer, think: mirror rotation). It is a sort-of regression of 78c72d0ce22e00b194251445aae306df357d5c1a, which removed the filesize - 1 trick, but this had its own problems… To properly test this our webserver gains the ability to reply with transfer-encoding: chunked as most real webservers will use it to send the dynamically generated error pages. Closes: 768797
Diffstat (limited to 'methods/https.cc')
-rw-r--r--methods/https.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/methods/https.cc b/methods/https.cc
index 366148e19..23b3a10d4 100644
--- a/methods/https.cc
+++ b/methods/https.cc
@@ -69,6 +69,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;
@@ -86,19 +89,25 @@ 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)
me->URIStart(me->Res);
- if(me->File->Write(buffer, size*nmemb) != true)
+ if(me->File->Write(buffer, buffer_size) != true)
return false;
if(me->Queue->MaximumSize > 0 && me->File->Tell() > me->Queue->MaximumSize)
{
me->SetFailReason("MaximumSizeExceeded");
- return _error->Error("Writing more data than expected (%llu > %llu)",
+ _error->Error("Writing more data than expected (%llu > %llu)",
me->TotalWritten, me->Queue->MaximumSize);
+ return 0;
}
- return size*nmemb;
+ return buffer_size;
}
int