started using the new http/1.1 support for testing apache-2.0 (in the
httpd-test project). things are working great except https is not
supported with http/1.1. it works with the patch below but requires the
following code:
require LWP::Protocol::https11;
LWP::Protocol::implementor('https', 'LWP::Protocol::https11');
would be great if 5.54 supports http/1.1 + https.
--- ./lib/LWP/Protocol/http11.pm~ Sun Aug 26 14:44:04 2001
+++ ./lib/LWP/Protocol/http11.pm Sun Aug 26 18:21:43 2001
@@ -24,9 +24,11 @@
{
package LWP::Protocol::MyHTTP;
- use vars qw(@ISA);
+ use vars qw(@ISA $Class);
@ISA = qw(Net::HTTP);
+ $Class = __PACKAGE__;
+
sub xread {
my $self = shift;
if (my $timeout = ${*$self}{io_socket_timeout}) {
@@ -67,7 +69,7 @@
}
local($^W) = 0; # IO::Socket::INET can be noisy
- my $sock = LWP::Protocol::MyHTTP->new(PeerAddr => $host,
+ my $sock = $LWP::Protocol::MyHTTP::Class->new(PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp',
Timeout => $timeout,
@@ -274,7 +276,7 @@
if ($r && @$r) {
# readable
my $buf = $socket->_rbuf;
- my $n = sysread($socket, $buf, 1024, length($buf));
+ my $n = $socket->sysread($buf, 1024, length($buf));
unless ($n) {
die "EOF";
}
@@ -340,7 +342,7 @@
my $complete;
$response = $self->collect($arg, $response, sub {
- my $buf;
+ my $buf = ""; #prevent use of uninitialized value
my $n;
READ:
{
--- ./lib/Net/HTTP.pm~ Thu Aug 2 16:30:44 2001
+++ ./lib/Net/HTTP.pm Sun Aug 26 18:21:49 2001
@@ -194,7 +194,7 @@
}
sub xread {
- sysread($_[0], $_[1], $_[2], $_[3] || 0);
+ $_[0]->sysread($_[1], $_[2], $_[3] || 0);
}
--- /dev/null Thu Aug 24 02:00:32 2000
+++ lib/LWP/Protocol/https11.pm Sun Aug 26 18:16:15 2001
@@ -0,0 +1,57 @@
+#
+# $Id: https.pm,v 1.8 1999/09/20 12:48:37 gisle Exp $
+
+use strict;
+
+package LWP::Protocol::https11;
+
+use vars qw(@ISA);
+
+require LWP::Protocol::http11;
+require LWP::Protocol::https;
+
+@ISA = qw(LWP::Protocol::http11);
+my $SSL_CLASS = $LWP::Protocol::https::SSL_CLASS;
+
+#used to avoid calling IO::Socket::INET::configure twice
+sub LWP::Protocol::https11::Noop::configure {$_[0]};
+
+#we need this to setup a proper @ISA tree
+{
+ package LWP::Protocol::MyHTTPS;
+ use vars qw(@ISA);
+ @ISA = ($SSL_CLASS, 'LWP::Protocol::MyHTTP');
+
+ #we need to call both Net::SSL::configure and Net::HTTP::configure
+ #however both call SUPER::configure (which is IO::Socket::INET)
+ #to avoid calling that twice we trick Net::HTTP into calling
+ #Noop::configure
+
+ sub configure {
+ my $self = shift;
+ local @Net::HTTP::ISA = qw(LWP::Protocol::https11::Noop);
+ for my $class (@ISA) {
+ my $cfg = $class->can('configure');
+ $cfg->($self, @_);
+ }
+ $self;
+ }
+}
+
+sub _new_socket
+{
+ #needs to be blessed into our pseudo class
+ local $LWP::Protocol::MyHTTP::Class = 'LWP::Protocol::MyHTTPS';
+ shift->SUPER::_new_socket(@_);
+}
+
+{
+ #if we inherit from LWP::Protocol::https we inherit from
+ #LWP::Protocol::http, so just setup aliases for these two
+ no strict 'refs';
+ for (qw(_check_sock _get_sock_info)) {
+ *{"$_"} = \&{"LWP::Protocol::https::$_"};
+ }
+}
+
+1;