David Dyck <[EMAIL PROTECTED]> writes:
> On Sat, 11 Mar 2000, David Dyck wrote:
>
> > head($url)
> > Get document headers. Returns the following 5 values if
> > successful: ($content_type, $document_length, $modi-
> > fied_time, $expires, $server)
> >
> > Returns an empty list if it fails. In scalar context
> > returns TRUE if successful.
>
>
> > Changing line 14 to read
> > HTTP::Date::str2time($response->header('Expires')) || undef,
> > or
> > scalar( HTTP::Date::str2time($response->header('Expires')) ),
> >
> > reserves the slot, so that the server header in returned
> > in the 5'th position.
>
> This patch fixes the problem for perl v5.6.0-RC1
>
> --- /jd/usr2/dcd/CPAN/Installed/libwww-perl-5.47/lib/LWP/Simple.pm Fri Mar 19
>23:37:36 1999
> +++ LWP/Simple.pm Sat Mar 11 14:20:37 2000
> @@ -220,8 +220,8 @@
> return $response unless wantarray;
> return (scalar $response->header('Content-Type'),
> scalar $response->header('Content-Length'),
> - HTTP::Date::str2time($response->header('Last-Modified')),
> - HTTP::Date::str2time($response->header('Expires')),
> + scalar( HTTP::Date::str2time($response->header('Last-Modified')) ),
> + scalar( HTTP::Date::str2time($response->header('Expires')) ),
> scalar $response->header('Server'),
> );
> }
I already had the following patch to HTTP::Date pending. It will also
fix the same problem.
Regards,
Gisle
Index: lib/HTTP/Date.pm
===================================================================
RCS file: /home/cvs/aas/perl/mods/libwww-perl/lib/HTTP/Date.pm,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -p -u -r1.39 -r1.40
--- lib/HTTP/Date.pm 1999/05/03 14:04:48 1.39
+++ lib/HTTP/Date.pm 2000/02/14 15:37:48 1.40
@@ -1,6 +1,6 @@
-package HTTP::Date; # $Date: 1999/05/03 14:04:48 $
+package HTTP::Date; # $Date: 2000/02/14 15:37:48 $
-$VERSION = sprintf("%d.%02d", q$Revision: 1.39 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 1.40 $ =~ /(\d+)\.(\d+)/);
require 5.004;
require Exporter;
@@ -34,7 +34,7 @@ sub time2str (;$)
sub str2time ($;$)
{
my $str = shift;
- return unless defined $str;
+ return undef unless defined $str;
# fast exit for strictly conforming string
if ($str =~ /^[SMTWF][a-z][a-z], (\d\d) ([JFMAJSOND][a-z][a-z]) (\d\d\d\d)
(\d\d):(\d\d):(\d\d) GMT$/) {
@@ -45,7 +45,7 @@ sub str2time ($;$)
}
my @d = parse_date($str);
- return unless @d;
+ return undef unless @d;
$d[0] -= 1900; # year
$d[1]--; # month
@@ -68,11 +68,11 @@ sub str2time ($;$)
$offset *= -1 if $1 && $1 ne '-';
}
else {
- eval { require Time::Zone } || return;
+ eval { require Time::Zone } || return undef;
$offset = Time::Zone::tz_offset($tz);
- return unless defined $offset;
+ return undef unless defined $offset;
}
-
+
return eval { my $t = Time::Local::timegm(reverse @d);
$t < 0 ? undef : $t + $offset;
};
@@ -222,7 +222,7 @@ sub parse_date ($)
return($yr, $mon, $day, $hr, $min, $sec, $tz)
if wantarray;
-
+
if (defined $tz) {
$tz = "Z" if $tz =~ /^(GMT|UTC?|[-+]?0+)$/;
} else {