Solved

LWP and Redirect (for example: MOVE)

Posted on 2006-11-29
2
339 Views
Last Modified: 2008-02-01
Hi,

When you sometimes get a page with LWP, it displays a MOVE message,
meaning that the page has been moved. Is it possible for LWP to then get the page on the new address?
i.e: Read and handle 301.

Greeting.
0
Comment
Question by:TonyJix
2 Comments
 
LVL 17

Expert Comment

by:mjcoyne
ID: 18036088
It depends on whether the server provides that information in some manner.  You could check LWP for a 301 error, and branch based on whether it's true or not.  You could then process the page that was returned, looking for the new address.  But, this address might or might not be there, depending on how the server is configured and on what the admin has decided to send on connect to the old address.  Moreover, if the re-direct page does provide the new address, it could be anywhere on the page, and is not garunteed to be the only URL on the page...
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 18036248
require LWP::UserAgent;
 
 my $ua = LWP::UserAgent->new;
 
 $ua->max_redirect( 7 );

 my $response = $ua->get('http://search.cpan.org/');
 
 if( $response->is_success ){
     print $response->content;  
 }else{
     die $response->status_line;
 }
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question