Skip Menu |
 

This queue is for tickets about the libwww-perl CPAN distribution.

Report information
The Basics
Id: 95988
Status: resolved
Priority: 0/
Queue: libwww-perl

People
Owner: Nobody in particular
Requestors: pagenyon [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: add option to automatically handle meta redirects
Download (untitled) / with headers
text/plain 552b
LWP already parses the head tag by default, and makes any contained meta http-equiv statements available as response headers. I suggest adding an option (like meta_redirect => 1) that would tell LWP to automatically follow these redirects. A web search shows this functionality has been asked for many times over the years, though it looks like no official feature request was made in RT or github. If there is a reason this will not be implemented, can you at least include an example in the docs on how the user can implement using request handlers.
From: pagenyon [...] gmail.com
On Mon May 26 18:21:39 2014, pagenyon wrote: Show quoted text
> LWP already parses the head tag by default, and makes any contained > meta http-equiv statements available as response headers. > I suggest adding an option (like meta_redirect => 1) that would tell > LWP to automatically follow these redirects. > > A web search shows this functionality has been asked for many times > over the years, though it looks like no official feature request was > made in RT or github. If there is a reason this will not be > implemented, can you at least include an example in the docs on how > the user can implement using request handlers.
figured out how to do with request handlers: $ua->set_my_handler(response_done => sub{ my ($response, $ua, $handler) = @_; if (my ($refresh) = $res->remove_header('Refresh')) { $refresh =~ s/.*?\burl=//; my $uri = URI->new($refresh)->canonical; return if ref $uri eq 'URI::_generic'; $response->code(301); $response->header(Location => $uri); } }, m_code => 200);
Subject: Re: [rt.cpan.org #95988] add option to automatically handle meta redirects
Date: Mon, 26 May 2014 16:15:42 -0700
To: pagenyon via RT <bug-libwww-perl [...] rt.cpan.org>
From: Karen Etheridge <ether [...] cpan.org>
Download (untitled) / with headers
text/plain 462b
On Mon, May 26, 2014 at 07:02:48PM -0400, pagenyon via RT wrote: Show quoted text
> return if ref $uri eq 'URI::_generic'; > $response->code(301); > $response->header(Location => $uri);
Checking for types like this is fragile -- the underscore is a hint that you shouldn't be depending on this name. Instead, check for the capabilities that you need - e.g. return unless $uri->can('scheme'), or return unless $uri->some_property eq $value.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.