What you're looking for is in perldoc HTTP::Response
(look at base(), previous(), and is_redirect())

use strict;
use LWP;

my $ua       = LWP::UserAgent->new();
my $request  = HTTP::Request->new('GET' => 'http://www.salon.com/media');
my $response = $ua->request($request);

print "base: ", $response->base(), "\n",
      $response->previous()->is_redirect()
      ? "(was redirected)\n" : "(was not redirected)\n";

Gisle has documented these modules for a reason... 

perldoc is your friend,

- Austin

On Mar 4, Baris Sumengen sprach thusly:

> Hello,
> I asked this before but I didn't get a full answer.
> 
> When I try to connect to:
> http://www.salon.com/media
> 
> The return message is:
> >HTTP/1.1 301 Moved Permanently
> >Date: Wed, 23 Feb 2000 21:39:49 GMT
> >Server: Apache/1.3.9 (Unix) PHP/3.0.12 mod_oas/4.63b
> >Location: http://www.salon.com/media/
> >Connection: close
> >Content-Type: text/html
> 
> But if I use LWP, I don't get the code 301.
> I get an "OK" message.
> LWP::Simple and LWP::UserAgent seems to follow "301" links. they don't give
> any warnings.
> I have to detect that:
> "http://www.salon.com/media" is permanently moved to
> "http://www.salon.com/media/"
> 
> How can I do it in LWP.
> Baris.
> 
> 
> 
> 
> ________________________________________________________
>                            1stUp.com - Free the Web�
>    Get your free Internet access at http://www.1stUp.com
> 

--
Get a book on tape:

  http://www.booksontape.com/cart/cart.cgi?link_from=01D1PK&load=index

Reply via email to