Apologies for sending a patch against an older version, but, due to some
reasons too complicated to go into, I can't currently use cutting-edge
code. This patch makes timeouts optional. Under Perl 5.00503, I was
getting an error because that version of Perl doesn't support socket
timeouts. This patch modifies LWP::Protocol::http::_new_socket() so that
it doesn't try to set the socket's Timeout option if the timeout value
is 0 or undefined.

To apply it,

tar xvzf libwww-perl-5.50.tar.gz
cd libwww-perl-5.50
patch -Np0 < libwww-perl-5.50-patch1

Since I'm not on the libwww list, please explicitly copy me on any
replies you'd like me to see.

thanks,
Jeff
diff -Naur lib/LWP/Protocol/http.pm lib.new/LWP/Protocol/http.pm
--- lib/LWP/Protocol/http.pm    Wed May 24 09:41:13 2000
+++ lib.new/LWP/Protocol/http.pm        Thu Sep 13 20:57:48 2001
@@ -25,12 +25,22 @@
     my($self, $host, $port, $timeout) = @_;
 
     local($^W) = 0;  # IO::Socket::INET can be noisy
-    my $sock = IO::Socket::INET->new(PeerAddr => $host,
-                                    PeerPort => $port,
-                                    Proto    => 'tcp',
-                                    Timeout  => $timeout,
-                                    $self->_extra_sock_opts($host, $port),
-                                   );
+    my $sock;
+    if ((defined $timeout) && ($timeout > 0)) {
+        $sock = IO::Socket::INET->new(PeerAddr => $host,
+                                     PeerPort => $port,
+                                     Proto    => 'tcp',
+                                     Timeout  => $timeout,
+                                     $self->_extra_sock_opts($host, $port),
+                                     );
+    }
+    else {
+        $sock = IO::Socket::INET->new(PeerAddr => $host,
+                                     PeerPort => $port,
+                                     Proto    => 'tcp',
+                                     $self->_extra_sock_opts($host, $port),
+                                     );
+    }
     unless ($sock) {
        # IO::Socket::INET leaves additional error messages in $@
        $@ =~ s/^.*?: //;

Reply via email to