Subject: | does not handle multiple links in one header line |
Date: | Fri, 6 Oct 2017 17:15:14 +0200 |
To: | bug-HTTP-Link-Parser [...] rt.cpan.org |
From: | Alexander Wuerstlein <arw [...] cs.fau.de> |
Hello,
multiple links in one Link:-header do not seem to be handled, just the
first link is returned. Failing test case is:
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 1;
use HTTP::Link::Parser ();
use HTTP::Response;
my $response = HTTP::Response->new( 200 );
$response->push_header("Base" => "http://example.org/subject");
# test analogous to topmost example on page 9 of RFC5988:
# Link: </TheBook/chapter2>;
# rel="previous"; title*=UTF-8'de'letztes%20Kapitel,
# </TheBook/chapter4>;
# rel="next"; title*=UTF-8'de'n%c3%a4chstes%20Kapitel
$response->push_header("Link" => "<https://example.com/prev>; rel=\"prev\", <https://example.com/next>; rel=\"next\"");
my @data = sort {
$a->{URI} cmp $b->{URI}
} @{ HTTP::Link::Parser::parse_links_to_list($response) };
is_deeply(
\@data,
[
{
'URI' => bless( do{\(my $o = 'https://example.com/next')}, 'URI::https' ),
'rel' => [ 'next' ]
},
{
'URI' => bless( do{\(my $o = 'https://example.com/prev')}, 'URI::https' ),
'rel' => [ 'prev' ]
}
]
) or diag explain(\@data);
Ciao,
Alexander Wuerstlein.