You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-commits@perl.apache.org by pg...@apache.org on 2006/09/07 04:45:58 UTC

svn commit: r440952 - /perl/Apache-Test/trunk/lib/Apache/TestClient.pm

Author: pgollucci
Date: Wed Sep  6 19:45:57 2006
New Revision: 440952

URL: http://svn.apache.org/viewvc?view=rev&rev=440952
Log:
Make
    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.

Compatible with an API I was not aware of
  my $str = POST_BODY $location, content => $expect;

  Here, content will be passed as part of the 
  @headers array to Apache::TestClient


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

Modified: perl/Apache-Test/trunk/lib/Apache/TestClient.pm
URL: http://svn.apache.org/viewvc/perl/Apache-Test/trunk/lib/Apache/TestClient.pm?view=diff&rev=440952&r1=440951&r2=440952
==============================================================================
--- perl/Apache-Test/trunk/lib/Apache/TestClient.pm (original)
+++ perl/Apache-Test/trunk/lib/Apache/TestClient.pm Wed Sep  6 19:45:57 2006
@@ -32,6 +32,18 @@
 sub request {
     my($method, $url, @headers) = @_;
 
+    my @real_headers = ();
+    my $content;
+
+    for (my $i = 0; $i < scalar @headers; $i += 2) {
+        if ($headers[$i] =~ /content/i) {
+            $content = $headers[$i+1];
+        }
+        else {
+            push @real_headers, ($headers[$i], $headers[$i+1]);
+        }
+    }
+
     ## XXX:
     ## This is not a FULL URL encode mapping
     ## space ' '; however is very common, so this
@@ -54,7 +66,6 @@
         return undef;
     }
 
-    my $content = delete $headers{'content'};
     if ($content) {
         $headers{'Content-Length'} ||= length $content;
         $headers{'Content-Type'}   ||= 'application/x-www-form-urlencoded';
@@ -69,8 +80,8 @@
 
     $request .= $CRLF;
 
-    for (my $i = 0; $i < scalar @headers; $i += 2) {
-        $request .= "$headers[$i]: $headers[$i+1]$CRLF";
+    for (my $i = 0; $i < scalar @real_headers; $i += 2) {
+        $request .= "$real_headers[$i]: $real_headers[$i+1]$CRLF";
     }
 
     $request .= $CRLF;