summaryrefslogtreecommitdiff
path: root/test/interactive-helper/aptwebserver.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2017-12-13 23:57:24 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2017-12-13 23:57:24 +0100
commit56f5df0df7ece30fbf3b773d249e3e783a09724f (patch)
tree6d71c3b920209bc6636893f34f6e619418bd719b /test/interactive-helper/aptwebserver.cc
parent99813a2eaa7c0cce1d7d8c811827733ed66458de (diff)
parent355e1aceac1dd05c4c7daf3420b09bd860fd169d (diff)
Merge branch 'feature/altretries'
Generalizing the behaviour of retrying a download on the same server (if enabled via options) as well as retrying a download via a different alternative server from the acquire item responsible for deb files to the handling of items in general so that all are effected.
Diffstat (limited to 'test/interactive-helper/aptwebserver.cc')
-rw-r--r--test/interactive-helper/aptwebserver.cc17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index 11f9b4b4f..4bc344178 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -82,7 +82,10 @@ static std::string httpcodeToStr(int const httpcode) /*{{{*/
case 504: return _config->Find("aptwebserver::httpcode::504", "504 Gateway Time-out");
case 505: return _config->Find("aptwebserver::httpcode::505", "505 HTTP Version not supported");
}
- return "";
+ std::string codeconf, code;
+ strprintf(codeconf, "aptwebserver::httpcode::%i", httpcode);
+ strprintf(code, "%i Unknown HTTP code", httpcode);
+ return _config->Find(codeconf, code);
}
/*}}}*/
static bool chunkedTransferEncoding(std::list<std::string> const &headers) {
@@ -696,6 +699,18 @@ static void * handleClient(int const client, size_t const id) /*{{{*/
}
}
+ // automatic retry can be tested with this
+ {
+ int failrequests = _config->FindI("aptwebserver::failrequest::" + filename, 0);
+ if (failrequests != 0)
+ {
+ --failrequests;
+ _config->Set(("aptwebserver::failrequest::" + filename).c_str(), failrequests);
+ sendError(log, client, _config->FindI("aptwebserver::failrequest", 400), *m, sendContent, "Server is configured to fail this file.", headers);
+ continue;
+ }
+ }
+
// deal with the request
unsigned int const httpsport = _config->FindI("aptwebserver::port::https", 4433);
std::string hosthttpsport;