Subject: | alternative patch for proxied environments |
perl-5.10.1 on RHEL5.6 & RHEL6.0
Net-HTTP-6.00
I'm building Net-HTTP on a RHEL5 x86 box, which bypasses our transparent proxies, and on
a RHEL6 x86 box, which is subject to transparent (Cisco WCCP) proxying. The later box is also
NATted by our border Cisco router, but I don't think that's relevant. The transparent proxy
also seems to use HTTP/1.0. The attached patch sees both boxes successfully run the
t/apache.t test.
Basically
* anything in the response past 'Accept: */*' is ignored
* if the response includes 'HTTP/1.0' the 'HTTP/1.1'
in the expected response is correspondingly changed
* if the response includes 'HTTP/1.0' the second loop
is not done.
I using CPANPLUS to install several hundred modules, and the failure of Net::HTTP to install
cascaded through the dependencies.
on RHEL5.6 box
# curl -I www.apache.org
HTTP/1.1 200 OK
Date: Sun, 17 Apr 2011 04:49:50 GMT
Server: Apache/2.3.8 (Unix) mod_ssl/2.3.8 OpenSSL/1.0.0c
Last-Modified: Sun, 17 Apr 2011 04:10:16 GMT
ETag: "d84d58-9d7f-4a11573cc5a00"
Accept-Ranges: bytes
Content-Length: 40319
Vary: Accept-Encoding
Cache-Control: max-age=3600
Expires: Sun, 17 Apr 2011 05:49:50 GMT
Content-Type: text/html
on RHEL6.0 box
# curl -I www.apache.org
HTTP/1.0 200 OK
Date: Sun, 17 Apr 2011 04:50:05 GMT
Server: Apache/2.3.8 (Unix) mod_ssl/2.3.8 OpenSSL/1.0.0c
Last-Modified: Sun, 17 Apr 2011 04:10:16 GMT
ETag: "d84d58-9d7f-4a11573cc5a00"
Accept-Ranges: bytes
Content-Length: 40319
Vary: Accept-Encoding
Cache-Control: max-age=3600
Expires: Sun, 17 Apr 2011 05:50:05 GMT
Content-Type: text/html
X-Cache: MISS from proxy10.uq.edu.au
X-Cache-Lookup: MISS from proxy10.uq.edu.au:80
Via: 1.1 proxy10.uq.edu.au:80 (squid/2.7.STABLE9)
Connection: close
Subject: | Net-HTTP-6.00.tar.gz.diff |
diff -u Net-HTTP-6.00.orig/t/apache.t Net-HTTP-6.00/t/apache.t
--- Net-HTTP-6.00.orig/t/apache.t 2011-02-28 00:44:27.000000000 +1000
+++ Net-HTTP-6.00/t/apache.t 2011-04-17 09:49:48.000000000 +1000
@@ -18,7 +18,7 @@
use strict;
use Test;
-plan tests => 6;
+#plan tests => 6;
use Net::HTTP;
@@ -29,7 +29,7 @@
PeerHTTPVersion => "1.1",
MaxLineLength => 512) || die "$@";
-for (1..2) {
+for my $pass (1..2) {
$s->write_request(TRACE => "/libwww-perl",
'User-Agent' => 'Mozilla/5.0',
'Accept-Language' => 'no,en',
@@ -42,8 +42,8 @@
}
print "\n";
- ok($code, "200");
- ok($h{'Content-Type'}, "message/http");
+# ok($code, "200");
+# ok($h{'Content-Type'}, "message/http");
my $buf;
while (1) {
@@ -54,13 +54,29 @@
}
$buf =~ s/\r//g;
- ok($buf, <<EOT);
+my $first_headers_expected =<<'EOT';
TRACE /libwww-perl HTTP/1.1
Host: www.apache.org
User-Agent: Mozilla/5.0
Accept-Language: no,en
Accept: */*
-
EOT
+ $buf = substr $buf, 0, length($first_headers_expected);
+ # some of our transparent proxies seem to downgrade
+ # the connection from HTTP/1.1
+ if ($buf =~ /HTTP\/1\.0/) {
+ $first_headers_expected =~ s/HTTP\/1\.1/HTTP\/1.0/;
+ plan tests => 3;
+ ok($code, "200");
+ ok($h{'Content-Type'}, "message/http");
+ ok($buf eq $first_headers_expected);
+ last;
+ } elsif ($pass == 1) {
+ plan tests => 6;
+ }
+ # move after 'plan tests'
+ ok($code, "200");
+ ok($h{'Content-Type'}, "message/http");
+ ok($buf eq $first_headers_expected);
}