http://qs321.pair.com?node_id=127156


in reply to Finding a redirect's URL

LWP allows you to make a request without LWP following redirects, etc. with the simple_request method of LWP::UserAgent. For example:

my $request = HTTP::Request->new("GET", "http://cnn.com/europe"); my $response = $ua->simple_request($request); print $response->header("Location"), "\n"; # http://europe.cnn.com

Also the HTTP::Response class has a previous method to get the previous response in a chain of responses (as occurs when LWP follows redirects):

my $request = HTTP::Request->new("GET", "http://cnn.com/europe"); my $response = $ua->request($request); print $response->previous->header("Location"), "\n"; # http://europe.cnn.com