summaryrefslogtreecommitdiffstats
path: root/debian/perl-framework/t/apache/byterange.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/byterange.t
parentAdding upstream version 2.4.38. (diff)
downloadapache2-1221c736f9a90756d47ea6d28320b6b83602dd2a.tar.xz
apache2-1221c736f9a90756d47ea6d28320b6b83602dd2a.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/byterange.t')
-rw-r--r--debian/perl-framework/t/apache/byterange.t57
1 files changed, 57 insertions, 0 deletions
diff --git a/debian/perl-framework/t/apache/byterange.t b/debian/perl-framework/t/apache/byterange.t
new file mode 100644
index 0000000..e439d1d
--- /dev/null
+++ b/debian/perl-framework/t/apache/byterange.t
@@ -0,0 +1,57 @@
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestRequest ();
+use Apache::TestCommon ();
+
+Apache::TestCommon::run_files_test(\&verify, 1);
+
+sub verify {
+ my($ua, $url, $file) = @_;
+ my $debug = $Apache::TestRequest::DebugLWP;
+
+ $url = Apache::TestRequest::resolve_url($url);
+ my $req = HTTP::Request->new(GET => $url);
+
+ my $total = 0;
+ my $chunk_size = 8192;
+
+ my $wanted = -s $file;
+
+ while ($total < $wanted) {
+ my $end = $total + $chunk_size;
+ if ($end > $wanted) {
+ $end = $wanted;
+ }
+
+ my $range = "bytes=$total-$end";
+ $req->header(Range => $range);
+
+ print $req->as_string if $debug;
+
+ my $res = $ua->request($req);
+ my $content_range = $res->header('Content-Range') || 'NONE';
+
+ $res->content("") if $debug and $debug == 1;
+ print $res->as_string if $debug;
+
+ if ($content_range =~ m:^bytes\s+(\d+)-(\d+)/(\d+):) {
+ my($start, $end, $total_bytes) = ($1, $2, $3);
+ $total += ($end - $start) + 1;
+ }
+ elsif ($total == 0 && $end == $wanted &&
+ $content_range eq 'NONE' && $res->code == 200) {
+ $total += $wanted;
+ }
+ else {
+ print "Range: $range\n";
+ print "Content-Range: $content_range\n";
+ last;
+ }
+ }
+
+ print "downloaded $total bytes, file is $wanted bytes\n";
+
+ ok $total == $wanted;
+}