perl-test-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pgollu...@apache.org
Subject svn commit: r439224 - in /perl/Apache-Test/trunk: Changes lib/Apache/TestClient.pm
Date Fri, 01 Sep 2006 07:54:07 GMT
Author: pgollucci
Date: Fri Sep  1 00:54:05 2006
New Revision: 439224

URL: http://svn.apache.org/viewvc?rev=439224&view=rev
Log:
Allow Apache::TestClient which is used when LWP is not installed
to accept mutiple headers of the same name.



Modified:
    perl/Apache-Test/trunk/Changes
    perl/Apache-Test/trunk/lib/Apache/TestClient.pm

Modified: perl/Apache-Test/trunk/Changes
URL: http://svn.apache.org/viewvc/perl/Apache-Test/trunk/Changes?rev=439224&r1=439223&r2=439224&view=diff
==============================================================================
--- perl/Apache-Test/trunk/Changes (original)
+++ perl/Apache-Test/trunk/Changes Fri Sep  1 00:54:05 2006
@@ -8,6 +8,10 @@
 
 =item 1.29-dev
 
+Allow Apache::TestClient which is used when LWP is not installed
+to accept mutiple headers of the same name.
+[Philip M. Gollucci]
+
 Add t_start_error_log_watch() and t_finish_error_log_watch()
 to the Apache::TestUtil API which are only exported unpon request.
 [Torsten Foertsch <torsten.foertsch@gmx.net>]

Modified: perl/Apache-Test/trunk/lib/Apache/TestClient.pm
URL: http://svn.apache.org/viewvc/perl/Apache-Test/trunk/lib/Apache/TestClient.pm?rev=439224&r1=439223&r2=439224&view=diff
==============================================================================
--- perl/Apache-Test/trunk/lib/Apache/TestClient.pm (original)
+++ perl/Apache-Test/trunk/lib/Apache/TestClient.pm Fri Sep  1 00:54:05 2006
@@ -30,16 +30,16 @@
 my $CRLF = "\015\012";
 
 sub request {
-    my($method, $url, $headers) = @_;
+    my($method, $url, @headers) = @_;
 
     my $config = Apache::Test::config();
 
     $method  ||= 'GET';
     $url     ||= '/';
-    $headers ||= {};
+    my %headers = ();
 
     my $hostport = Apache::TestRequest::hostport($config);
-    $headers->{Host} = (split ':', $hostport)[0];
+    $headers{Host} = (split ':', $hostport)[0];
 
     my $s = Apache::TestRequest::vhost_socket();
 
@@ -48,18 +48,26 @@
         return undef;
     }
 
-    my $content = delete $headers->{'content'};
+    my $content = delete $headers{'content'};
     if ($content) {
-        $headers->{'Content-Length'} ||= length $content;
-        $headers->{'Content-Type'}   ||= 'application/x-www-form-urlencoded';
+        $headers{'Content-Length'} ||= length $content;
+        $headers{'Content-Type'}   ||= 'application/x-www-form-urlencoded';
     }
 
     #for modules/setenvif
-    $headers->{'User-Agent'} ||= 'libwww-perl/0.00';
+    $headers{'User-Agent'} ||= 'libwww-perl/0.00';
 
     my $request = join $CRLF,
       "$method $url HTTP/1.0",
-      (map { "$_: $headers->{$_}" } keys %$headers), $CRLF;
+      (map { "$_: $headers{$_}" } keys %headers);
+
+    $request .= $CRLF;
+
+    for (my $i = 0; $i < scalar @headers; $i += 2) {
+        $request .= "$headers[$i]: $headers[$i+1]$CRLF";
+    }
+
+    $request .= $CRLF;
 
     # using send() avoids the need to use SIGPIPE if the server aborts
     # the connection
@@ -123,8 +131,7 @@
     no strict 'refs';
     *$method = sub {
         my $url = shift;
-        my $headers = { @_ };
-        request($method, $url, $headers);
+        request($method, $url, @_);
     };
 }
 



Mime
View raw message