From d94b1d80d8326334d17f6a43061368e783b8e0aa Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Aug 2016 18:24:35 +0200 Subject: don't sent Range requests if we know its not accepted If the server told us in a previous request that it isn't supporting Ranges with bytes via an Accept-Ranges header missing bytes, we don't try to formulate requests using Ranges. --- test/interactive-helper/aptwebserver.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/interactive-helper/aptwebserver.cc') diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc index c32f286b2..950a17bc1 100644 --- a/test/interactive-helper/aptwebserver.cc +++ b/test/interactive-helper/aptwebserver.cc @@ -717,6 +717,15 @@ static void * handleClient(void * voidclient) /*{{{*/ condition.clear(); if (condition.empty() == false && strncmp(condition.c_str(), "bytes=", 6) == 0) { + std::string ranges = ',' + _config->Find("aptwebserver::response-header::Accept-Ranges") + ','; + ranges.erase(std::remove(ranges.begin(), ranges.end(), ' '), ranges.end()); + if (ranges.find(",bytes,") == std::string::npos) + { + // we handle it as an error here because we are a test server - a real one should just ignore it + sendError(client, 400, *m, sendContent, "Client does range requests we don't support", headers); + continue; + } + time_t cache; std::string ifrange; if (_config->FindB("aptwebserver::support::if-range", true) == true) -- cgit v1.2.3