[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

LWP and Redirect (for example: MOVE)

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
TonyJix
Asked:
TonyJix
1 Solution
 
mjcoyneCommented:
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
 
ozoCommented:
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now