diff options
author | David Kalnischkies <david@kalnischkies.de> | 2016-08-11 18:24:35 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2016-08-16 18:49:37 +0200 |
commit | d94b1d80d8326334d17f6a43061368e783b8e0aa (patch) | |
tree | 7b248c4adecf84184dc823ada6f654c7e0f46f06 /test | |
parent | ebdb6f1810a20ac240b5b2192dc2e6532ff149d2 (diff) |
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.
Diffstat (limited to 'test')
-rwxr-xr-x | test/integration/test-apt-update-transactions | 2 | ||||
-rwxr-xr-x | test/integration/test-bug-lp1445239-download-loop | 1 | ||||
-rwxr-xr-x | test/integration/test-partial-file-support | 8 | ||||
-rwxr-xr-x | test/integration/test-releasefile-verification | 2 | ||||
-rw-r--r-- | test/interactive-helper/aptwebserver.cc | 9 |
5 files changed, 17 insertions, 5 deletions
diff --git a/test/integration/test-apt-update-transactions b/test/integration/test-apt-update-transactions index d8154b283..ab678c133 100755 --- a/test/integration/test-apt-update-transactions +++ b/test/integration/test-apt-update-transactions @@ -82,7 +82,7 @@ testsetup 'file' changetowebserver webserverconfig 'aptwebserver::support::modified-since' 'false' "$1" webserverconfig 'aptwebserver::support::last-modified' 'false' "$1" # curl is clever and sees hits here also -webserverconfig 'aptwebserver::support::range' 'false' "$1" +webserverconfig 'aptwebserver::response-header::Accept-Ranges' 'none' "$1" testsetup 'http' diff --git a/test/integration/test-bug-lp1445239-download-loop b/test/integration/test-bug-lp1445239-download-loop index a12d5252d..6802840a5 100755 --- a/test/integration/test-bug-lp1445239-download-loop +++ b/test/integration/test-bug-lp1445239-download-loop @@ -12,7 +12,6 @@ setupenvironment configarchitecture 'amd64' changetowebserver -webserverconfig 'aptwebserver::support::range' 'true' TESTFILE='aptarchive/testfile' dd if=/dev/zero of=$TESTFILE bs=100k count=1 2>/dev/null diff --git a/test/integration/test-partial-file-support b/test/integration/test-partial-file-support index 1c5d120d8..9b5eed1e5 100755 --- a/test/integration/test-partial-file-support +++ b/test/integration/test-partial-file-support @@ -96,6 +96,7 @@ followuprequest() { testrun() { webserverconfig 'aptwebserver::support::range' 'true' + webserverconfig 'aptwebserver::response-header::Accept-Ranges' 'bytes' local DOWN='./downloaded/testfile' copysource $TESTFILE 0 $DOWN @@ -125,7 +126,11 @@ testrun() { testdownloadfile 'old data' "${1}/testfile" "$DOWN" '=' testwebserverlaststatuscode '200' "$DOWNLOADLOG" - webserverconfig 'aptwebserver::support::range' 'false' + if [ "${1%%:*}" = 'https' ] && expr match "$1" "^.*/redirectme$" >/dev/null; then + webserverconfig 'aptwebserver::response-header::Accept-Ranges' 'none' + else + webserverconfig 'aptwebserver::support::range' 'false' + fi copysource $TESTFILE 20 $DOWN testdownloadfile 'no server support' "${1}/testfile" "$DOWN" '=' @@ -148,4 +153,5 @@ changetohttpswebserver serverconfigs "https://localhost:${APTHTTPSPORT}" webserverconfig 'aptwebserver::redirect::replace::/redirectme/' "https://localhost:${APTHTTPSPORT}/" +serverconfigs "https://localhost:${APTHTTPSPORT}/redirectme" serverconfigs "http://localhost:${APTHTTPPORT}/redirectme" diff --git a/test/integration/test-releasefile-verification b/test/integration/test-releasefile-verification index 82e48ffa8..fec7b1302 100755 --- a/test/integration/test-releasefile-verification +++ b/test/integration/test-releasefile-verification @@ -12,8 +12,6 @@ buildaptarchive setupflataptarchive changetowebserver -webserverconfig 'aptwebserver::support::range' 'false' - prepare() { local DATE="${2:-now}" if [ "$DATE" = 'now' ]; then 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) |