CC: | ivan [...] bessarabov.ru |
Subject: | When getting page with LWP 2 dots in url is not working as expected |
I'm using LWP to get page content. Sometimes I have the link that has
two dots in it. E.g. "http://google.com/analytics/../support/". When I
enter this link in address bar in any browser I see the desired page
"http://google.com/analytics/support/". But when I try to get that page
with LWP I get 404 error, because it does not parse url before sending
it to the server.
Here is a code showing this problem:
{{{
#! /usr/bin/perl
use strict;
use warnings;
use LWP;
my $link = 'http://google.com/analytics/../support/';
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => "$link");
my $response = $ua->request($req);
$response->content =~ /<title>(.*)<\/title>/;
print "$1";
}}}