libwww-perl / HTTP-Message

The HTTP-Message distribution contains classes useful for representing the messages passed in HTTP style communication.
https://metacpan.org/pod/HTTP::Message
Other
28 stars 61 forks source link

if_modified_since calls time2str and dies [rt.cpan.org #105924] #78

Open oalders opened 7 years ago

oalders commented 7 years ago

Migrated from rt.cpan.org#105924 (status was 'open')

Requestors:

From nhorne@cpan.org on 2015-07-17 23:20:27:

The documentation at http://search.cpan.org/~ether/HTTP-Message-6.08/lib/HTTP/Headers.pm does not specify the format of the argument to HTTP::Headers::if_modified_since.  Reading the spec at  http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html I assumed H::H::if_modified_since takes a date field.  But H::H::if_modified_since has this code which dies in time2str because it's already a string:

    if (defined $time) {
    $self->_header($header, HTTP::Date::time2str($time));
    }

Here's my stack trace of the fault:

2015/07/17 14:43:27 TRACE> 0: bb-links.fcgi:103 main::__ANON__ - /home/hornenj/perlmods/share/perl/5.14.2/HTTP/Headers.pm:304 in function HTTP::Date::time2str
2015/07/17 14:43:27 TRACE> 0: bb-links.fcgi:103 main::__ANON__ - /home/hornenj/perlmods/share/perl/5.14.2/HTTP/Headers.pm:314 in function HTTP::Headers::_date_header
2015/07/17 14:43:27 TRACE> 0: bb-links.fcgi:103 main::__ANON__ - /home/hornenj/perlmods/share/perl/5.14.2/HTTP/Message.pm:644 in function HTTP::Headers::if_modified_since
2015/07/17 14:43:27 TRACE> 0: bb-links.fcgi:103 main::__ANON__ - bb-links.fcgi:2325 in function HTTP::Message::__ANON__

From ether@cpan.org on 2015-07-18 04:47:53:

Since it's dying in time2str, that would suggest it's expecting a value in
machine time (seconds since epoch), surely?

On Fri, Jul 17, 2015 at 4:20 PM, Nigel Horne via RT <
bug-HTTP-Message@rt.cpan.org> wrote:

> Fri Jul 17 19:20:27 2015: Request 105924 was acted upon.
> Transaction: Ticket created by NHORNE
>        Queue: HTTP-Message
>      Subject: if_modified_since calls time2str and dies
>    Broken in: 6.08
>     Severity: Important
>        Owner: Nobody
>   Requestors: NHORNE@cpan.org
>       Status: new
>  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=105924 >
>
>
> The documentation at
> http://search.cpan.org/~ether/HTTP-Message-6.08/lib/HTTP/Headers.pm does
> not specify the format of the argument to
> HTTP::Headers::if_modified_since.  Reading the spec at
> http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html I assumed
> H::H::if_modified_since takes a date field.  But H::H::if_modified_since
> has this code which dies in time2str because it's already a string:
>
>     if (defined $time) {
>         $self->_header($header, HTTP::Date::time2str($time));
>     }
>
> Here's my stack trace of the fault:
>
> 2015/07/17 14:43:27 TRACE> 0: bb-links.fcgi:103 main::__ANON__ -
> /home/hornenj/perlmods/share/perl/5.14.2/HTTP/Headers.pm:304 in function
> HTTP::Date::time2str
> 2015/07/17 14:43:27 TRACE> 0: bb-links.fcgi:103 main::__ANON__ -
> /home/hornenj/perlmods/share/perl/5.14.2/HTTP/Headers.pm:314 in function
> HTTP::Headers::_date_header
> 2015/07/17 14:43:27 TRACE> 0: bb-links.fcgi:103 main::__ANON__ -
> /home/hornenj/perlmods/share/perl/5.14.2/HTTP/Message.pm:644 in function
> HTTP::Headers::if_modified_since
> 2015/07/17 14:43:27 TRACE> 0: bb-links.fcgi:103 main::__ANON__ -
> bb-links.fcgi:2325 in function HTTP::Message::__ANON__
>
openstrike commented 7 years ago

I have added a test to t/headers.t in 1dc82f91f1093a1b15e94d6c323085f890d295d2 which does not reproduce the reported behaviour - ie. it does not die.

Perhaps the reporter was using an outdated version of HTTP::Date and the fatality there has since been trapped? My tests pass with HTTP::Date 6.02

robrwo commented 6 years ago

HTTP::Date 6.00 was when it was split into a separate distribution. So I would amend the prereqs to specify that as the minimum version.

Actually, since that already is the minimum version, and has been since after the RT bug was filed, I would close this issue.