Subject: | LWP::UserAgent doesn't follow "location" (lower-case "Location") headers |
When using LWP::UserAgent to interface with imageshack.us the library
stopped following location: header redirects since it only looks for the
upper-case Location: header (see attached file for example response).
This is probably RFC incompliant behavior violating section "14.30
Location" of RFC 2616, nevertheless Firefox -- and I presume all other
major browsers as imageshack is a major website -- will follow the
lower-case form.
The workaround is to do something like the following in the program
using LWP::UserAgent:
# Imageshack sets a "location" (not a "Location") header
my $location = $res->header("location");
my $res2 = $ua->get($location);
But perhaps libwww-perl should support this abuse of the HTTP spec?
Subject: | location-header.txt |
HTTP/1.1 302 Found
X-Powered-By: PHP/5.2.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: latest=img60; expires=Fri, 05-Mar-2010 13:12:15 GMT; path=/; domain=.imageshack.us
Set-Cookie: always_opt=-1; path=/; domain=.imageshack.us
Set-Cookie: rem_bar=-1; path=/; domain=.imageshack.us
location: http://img60.imageshack.us/content.php?page=done&l=img60/7083/img9732.jpg
Content-type: text/html
Transfer-Encoding: chunked
Connection: close
Date: Tue, 10 Mar 2009 13:12:20 GMT
Server: lighttpd/1.5.0
1
0