summaryrefslogtreecommitdiffstats
path: root/debian/perl-framework/t/apache/maxranges.t
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-07 02:04:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-07 02:04:07 +0000
commit1221c736f9a90756d47ea6d28320b6b83602dd2a (patch)
treeb453ba7b1393205258c9b098a773b4330984672f /debian/perl-framework/t/apache/maxranges.t
parentAdding upstream version 2.4.38. (diff)
downloadapache2-debian.tar.xz
apache2-debian.zip
Adding debian version 2.4.38-3+deb10u8.debian/2.4.38-3+deb10u8debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/perl-framework/t/apache/maxranges.t')
-rw-r--r--debian/perl-framework/t/apache/maxranges.t70
1 files changed, 70 insertions, 0 deletions
diff --git a/debian/perl-framework/t/apache/maxranges.t b/debian/perl-framework/t/apache/maxranges.t
new file mode 100644
index 0000000..015a474
--- /dev/null
+++ b/debian/perl-framework/t/apache/maxranges.t
@@ -0,0 +1,70 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestRequest;
+use Apache::TestUtil qw(t_write_file);
+
+# test multi-byterange-requests with overlaps (merges)
+
+my $url = "/apache/chunked/byteranges.txt";
+my $file = Apache::Test::vars('serverroot') . "/htdocs$url";
+
+my $content = "";
+$content .= sprintf("%04d", $_) for (1 .. 2000);
+t_write_file($file, $content);
+my $clen = length($content);
+
+
+my $medrange = "";
+my $longrange = "";
+my $i;
+
+for (0 .. 50) {
+ $longrange .= "0-1,3-4,0-1,3-4,";
+ if ($_ % 2) {
+ $medrange .= "0-1,3-4,0-1,3-4,";
+ }
+}
+
+my @test_cases = (
+ { url => "/maxranges/default/byteranges.txt" , h => "0-100", status => "206"},
+ { url => "/maxranges/default/byteranges.txt" , h => $medrange, status => "206"},
+ { url => "/maxranges/default/byteranges.txt" , h => $longrange, status => "200"},
+
+ { url => "/maxranges/default-explicit/byteranges.txt" , h => "0-100", status => "206"},
+ { url => "/maxranges/default-explicit/byteranges.txt" , h => $medrange, status => "206"},
+ { url => "/maxranges/default-explicit/byteranges.txt" , h => $longrange, status => "200"},
+
+ { url => "/maxranges/none/byteranges.txt" , h => "0-100", status => "200"},
+ { url => "/maxranges/none/byteranges.txt" , h => "$medrange", status => "200"},
+ { url => "/maxranges/none/byteranges.txt" , h => "$longrange", status => "200"},
+
+ { url => "/maxranges/1/merge/none/byteranges.txt" , h => "0-100", status => "200"},
+ { url => "/maxranges/1/merge/none/byteranges.txt" , h => "$medrange", status => "200"},
+ { url => "/maxranges/1/merge/none/byteranges.txt" , h => "$longrange", status => "200"},
+
+ { url => "/maxranges/1/byteranges.txt" , h => "0-100", status => "206"},
+ { url => "/maxranges/1/byteranges.txt" , h => "0-100,200-300", status => "200"},
+ { url => "/maxranges/2/byteranges.txt" , h => "0-100,200-300", status => "206"},
+ { url => "/maxranges/2/byteranges.txt" , h => "0-100,200-300,400-500", status => "200"},
+ { url => "/maxranges/unlimited/byteranges.txt" , h => "0-100", status => "206"},
+ { url => "/maxranges/unlimited/byteranges.txt" , h => "$medrange", status => "206"},
+ { url => "/maxranges/unlimited/byteranges.txt" , h => "$longrange", status => "206"},
+
+);
+plan tests => scalar(@test_cases), need need_lwp, need_min_apache_version('2.3.15') || need_min_apache_version('2.2.21'),
+ need_module('mod_alias');
+
+
+foreach my $test (@test_cases) {
+ my $result = GET $test->{"url"}, "Range" => "bytes=" . $test->{"h"} ;
+ my $boundary;
+ my $ctype = $result->header("Content-Type");
+ if ($test->{"status"} ne $result->code()) {
+ print "Wrong status code: " . $result->code() ."\n";
+ ok(0);
+ next;
+ }
+ ok (1);
+}