Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the WWW-Mechanize CPAN distribution.

Report information
The Basics
Id: 9126
Status: rejected
Priority: 0/
Queue: WWW-Mechanize

People
Owner: andy [...] petdance.com
Requestors: juanmarcosmoren [...] terra.es
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)

Attachments
WWW-Mechanize_get_abs_link.diff



Subject: make $mech->find_link() return absolute links
Download (untitled) / with headers
text/plain 409b
When doing something like: my @download_urls = $agent->find_all_links(); foreach my $download_url (@download_urls) { $res = $agent->get( $download_url ); } Doesn't work because the links are relative. Shouldn't always them be absolute, like browsers do when you copy a link? I don't know why anyone would like relative links. At least "$res = $agent->get( $download_url );" should work with relative links.
Date: Fri, 24 Dec 2004 10:43:52 -0500
From: Mark Stosberg <mark [...] summersault.com>
To: Guest via RT <bug-WWW-Mechanize [...] rt.cpan.org>
Subject: Re: [cpan #9126] make $mech->find_link() return absolute links
RT-Send-Cc:
Download (untitled) / with headers
text/plain 1022b
On Fri, Dec 24, 2004 at 08:51:56AM -0500, Guest via RT wrote: Show quoted text
> > This message about WWW-Mechanize was sent to you by guest <> via rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=9126 > > > When doing something like: > my @download_urls = $agent->find_all_links(); > foreach my $download_url (@download_urls) { > $res = $agent->get( $download_url ); > } > > Doesn't work because the links are relative. > Shouldn't always them be absolute, like browsers do when you copy a link? > I don't know why anyone would like relative links.
This is a reasonable suggestion. I don't see many drawbacks to this. Show quoted text
> At least "$res = $agent->get( $download_url );" should work with relative links.
I think it does if you do this: my @download_urls = $agent->find_all_links(); foreach my $download_url (@download_urls) { $res = $agent->get( $download_url ); # You have to back to be relative to the right place. $agent->back(); } Mark
From: juanmarcosmoren [...] terra.es
Download (untitled) / with headers
text/plain 456b
[mark@summersault.com - Fri Dec 24 11:06:59 2004]: Show quoted text
> > At least "$res = $agent->get( $download_url );" should work with
> relative links. > > I think it does if you do this: > > my @download_urls = $agent->find_all_links(); > foreach my $download_url (@download_urls) { > $res = $agent->get( $download_url ); > # You have to back to be relative to the right place. > $agent->back(); > }
I couldn't get it working even for the first URL, could you?
Download (untitled) / with headers
text/plain 727b
[guest - Fri Dec 24 11:38:56 2004]: Show quoted text
> [mark@summersault.com - Fri Dec 24 11:06:59 2004]:
> > > At least "$res = $agent->get( $download_url );" should work with
> > relative links. > > > > I think it does if you do this: > > > > my @download_urls = $agent->find_all_links(); > > foreach my $download_url (@download_urls) { > > $res = $agent->get( $download_url ); > > # You have to back to be relative to the right place. > > $agent->back(); > > }
> > I couldn't get it working even for the first URL, could you?
According to our test suite, things are working. If you think have found a bug, please submit a test case that illutrates it, preferably using Test::More. If the first link isn't working, that's a bug.
From: juanmarcosmoren [...] terra.es
Download (untitled) / with headers
text/plain 335b
[MARKSTOS - Sat Dec 25 15:36:52 2004]: Show quoted text
> According to our test suite, things are working. If you think have found > a bug, please submit a test case that illutrates it, preferably using > Test::More. > > If the first link isn't working, that's a bug.
Where in the test suite there's a ->get() using a relative WWW::Mechanize::Link?
From: juanmarcosmoren [...] terra.es
Maybe this is the correct fix. At least it works for me.
--- WWW/Mechanize.pm +++ WWW/Mechanize.pm @@ -313,7 +313,7 @@ my $self = shift; my $uri = shift; - $uri = $uri->url if ref($uri) eq 'WWW::Mechanize::Link'; + $uri = $uri->url_abs if ref($uri) eq 'WWW::Mechanize::Link'; $uri = $self->base ? URI->new_abs( $uri, $self->base )
Date: Sat, 25 Dec 2004 20:01:21 -0500
From: Mark Stosberg <mark [...] summersault.com>
To: Guest via RT <bug-WWW-Mechanize [...] rt.cpan.org>
Subject: Re: [cpan #9126] make $mech->find_link() return absolute links
RT-Send-Cc:
Download (untitled) / with headers
text/plain 404b
On Sat, Dec 25, 2004 at 06:06:40PM -0500, Guest via RT wrote: Show quoted text
> > This message about WWW-Mechanize was sent to you by guest <> via rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=9126 > > > Maybe this is the correct fix. > At least it works for me.
Thanks. I'll look into this further. And happy holidays. :) Mark
From: juanmarcosmoren [...] terra.es
Download (untitled) / with headers
text/plain 165b
[mark@summersault.com - Sat Dec 25 20:01:53 2004]: Show quoted text
> I'll look into this further.
Did someone take a look into this? I really think this should be fixed, don't you?
Download (untitled) / with headers
text/plain 214b
Show quoted text
> Did someone take a look into this? > I really think this should be fixed, don't you?
"Fix" is such a loaded word. You can use the $link->url_abs() method to get the absolute URL for whatever links you get back.
Download (untitled) / with headers
text/plain 451b
[PETDANCE - Sat Feb 12 20:56:50 2005]: Show quoted text
> "Fix" is such a loaded word. > > You can use the $link->url_abs() method to get the absolute URL for > whatever links you get back.
Don't you think that my first test case should work? Making it work, won't break anything and would make WWW::Mechanize user's life much easier. my @download_urls = $agent->find_all_links(); foreach my $download_url (@download_urls) { $res = $agent->get( $download_url ); }
Download (untitled) / with headers
text/plain 326b
Show quoted text
> Don't you think that my first test case should work? > Making it work, won't break anything and would make WWW::Mechanize > user's life much easier.
Mech needs to return the URL as it appears in the page. Links are relative to the page they appear on, and I have no intention of changing the way it Mech handles that fact.
From: juanmarcosmoren [...] terra.es
Download (untitled) / with headers
text/plain 547b
[PETDANCE - Sun Feb 13 16:59:20 2005]: Show quoted text
> > Don't you think that my first test case should work? > > Making it work, won't break anything and would make WWW::Mechanize > > user's life much easier.
> > Mech needs to return the URL as it appears in the page. Links are > relative to the page they appear on, and I have no intention of changing > the way it Mech handles that fact.
Sure, Mech needs to return the URL as it appears in the page, but I was referring to having $mech->get() accepting relative links instead of giving an unuseful error.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.