For your purposes, it's probably simpler to just compare the URL of the final HTTP::Response object with the one you gave to the UserAgent. If they're different, you must have encountered some sort of redirect:use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $url = "http://imdb.com/find?nm=on;mx=20;q=eliza%20dushku"; my $response = $ua->get($url); my @chain = ( $response ); while ( $chain[0]->previous ) { unshift @chain, $chain[0]->previous; } for (@chain) { printf "%s %s --> %s\n" => $_->request->method, $_->request->url->as_string, $_->status_line; } __END__ GET http://imdb.com/find?nm=on;mx=20;q=eliza%20dushku --> 302 Found GET http://imdb.com/name/nm0244630/ --> 200 OK
my $response = $ua->get($url); if ( $response->request->url->as_string ne $url ) { ... }
blokhead
In reply to Re: How to tell if a URL returned a Location: header?
by blokhead
in thread How to tell if a URL returned a Location: header?
by Cody Pendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |