You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@apache.org on 2011/08/28 22:46:50 UTC

svn commit: r1162589 - in /httpd/test/framework/trunk/t: apache/maxranges.t conf/extra.conf.in

Author: covener
Date: Sun Aug 28 20:46:50 2011
New Revision: 1162589

URL: http://svn.apache.org/viewvc?rev=1162589&view=rev
Log:
maxranges tests

Added:
    httpd/test/framework/trunk/t/apache/maxranges.t
      - copied, changed from r1162432, httpd/test/framework/trunk/t/apache/byterange.t
Modified:
    httpd/test/framework/trunk/t/conf/extra.conf.in

Copied: httpd/test/framework/trunk/t/apache/maxranges.t (from r1162432, httpd/test/framework/trunk/t/apache/byterange.t)
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/apache/maxranges.t?p2=httpd/test/framework/trunk/t/apache/maxranges.t&p1=httpd/test/framework/trunk/t/apache/byterange.t&r1=1162432&r2=1162589&rev=1162589&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/apache/byterange.t (original)
+++ httpd/test/framework/trunk/t/apache/maxranges.t Sun Aug 28 20:46:50 2011
@@ -2,56 +2,55 @@ use strict;
 use warnings FATAL => 'all';
 
 use Apache::Test;
-use Apache::TestRequest ();
-use Apache::TestCommon ();
+use Apache::TestRequest;
+use Apache::TestUtil qw(t_write_file);
 
-Apache::TestCommon::run_files_test(\&verify, 1);
+# 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);
 
-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";
+my $medrange = "";
+my $longrange = "";
+my $i;
 
-    ok $total == $wanted;
+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/0/byteranges.txt" ,       h => "0-100", status => "206"},
+    { url => "/maxranges/0/byteranges.txt" ,       h => "$medrange", status => "206"},
+    { url => "/maxranges/0/byteranges.txt" ,       h => "$longrange", status => "206"},
+    { 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"},
+);
+plan tests => scalar(@test_cases), need need_lwp, need_min_apache_version('2.3.15'), 
+              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);
 }

Modified: httpd/test/framework/trunk/t/conf/extra.conf.in
URL: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/conf/extra.conf.in?rev=1162589&r1=1162588&r2=1162589&view=diff
==============================================================================
--- httpd/test/framework/trunk/t/conf/extra.conf.in (original)
+++ httpd/test/framework/trunk/t/conf/extra.conf.in Sun Aug 28 20:46:50 2011
@@ -821,3 +821,19 @@ LimitRequestFields    32
   </IfVersion>
 </IfDefine>
 
+<IfDefine APACHE2>
+  <IfVersion >= 2.3.15>
+    <IfModule mod_alias.c>
+      AliasMatch /maxranges/([^/])+/ @SERVERROOT@/htdocs/apache/chunked/byteranges.txt
+      <Location /maxranges/0/>
+        MaxRanges 0 
+      </Location>
+      <Location /maxranges/1/>
+        MaxRanges 1
+      </Location>
+      <Location /maxranges/2/>
+        MaxRanges 2
+      </Location>
+    </IfModule>
+  </IfVersion>
+</IfDefine>