httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r1161665 - /httpd/test/framework/trunk/t/apache/byterange3.t
Date Thu, 25 Aug 2011 17:47:21 GMT
Author: jim
Date: Thu Aug 25 17:47:21 2011
New Revision: 1161665

URL: http://svn.apache.org/viewvc?rev=1161665&view=rev
Log:
Stupid simple test for merging and if it works

Added:
    httpd/test/framework/trunk/t/apache/byterange3.t

Added: httpd/test/framework/trunk/t/apache/byterange3.t
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/apache/byterange3.t?rev=1161665&view=auto
==============================================================================
--- httpd/test/framework/trunk/t/apache/byterange3.t (added)
+++ httpd/test/framework/trunk/t/apache/byterange3.t Thu Aug 25 17:47:21 2011
@@ -0,0 +1,58 @@
+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 $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";
+        $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;
+        }
+        else {
+            print "Range:         $range\n";
+            print "Content-Range: $content_range\n";
+            last;
+        }
+    }
+
+    print "downloaded $total bytes, file is $wanted bytes\n";
+
+    ok $total == $wanted;
+}



Mime
View raw message