diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 06:33:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 06:33:51 +0000 |
commit | 4f0770f3df78ecd5dcaefbd214f7a1415366bca6 (patch) | |
tree | 72661b8f81594b855bcc967b819263f63fa30e17 /debian/perl-framework/t/apache/byterange3.t | |
parent | Adding upstream version 2.4.56. (diff) | |
download | apache2-4f0770f3df78ecd5dcaefbd214f7a1415366bca6.tar.xz apache2-4f0770f3df78ecd5dcaefbd214f7a1415366bca6.zip |
Adding debian version 2.4.56-1~deb11u2.debian/2.4.56-1_deb11u2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | debian/perl-framework/t/apache/byterange3.t | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/debian/perl-framework/t/apache/byterange3.t b/debian/perl-framework/t/apache/byterange3.t new file mode 100644 index 0000000..56932f1 --- /dev/null +++ b/debian/perl-framework/t/apache/byterange3.t @@ -0,0 +1,73 @@ +use strict; +use warnings FATAL => 'all'; + +use Apache::Test; +use Apache::TestRequest (); +use Apache::TestCommon (); + +# test merging of byte ranges + +if (Apache::Test::need_min_apache_version("2.3.15")) { + Apache::TestCommon::run_files_test(\&verify, 1); +} +else { + plan tests => 0; +} + +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 $t1 = $total+1; + my $t10 = $total+5; + my $e1 = $end-1; + my $e20 = $end-10; + #my $range = "bytes=$total-$end"; + my $range = "bytes=$t10-$end,$total-$e1,$t10-$e20,$total-$e1"; + if ($end - $total < 15) { + # make sure to not send invalid ranges with start > end + $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; +} |