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: 12786
Status: rejected
Priority: 0/
Queue: WWW-Mechanize

People
Owner: Nobody in particular
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.12
Fixed in: (no value)



Subject: ->uri shows the wrong URL after redirects
Download (untitled) / with headers
text/plain 429b
The ->uri method of WWW::Mechanize does not show the correct URL if the agent was redirected. However, using the ->uri method of the underlying HTTP::Request object shows the correct output. Here's a sample script. use WWW::Mechanize; $agent = WWW::Mechanize->new; $agent->get("http://bbbike.de"); warn $agent->uri; # the URL stays the same warn $agent->response->request->uri; # the correct redirected URL Regards, Slaven
Appears to be a dupe of bug 12882. http://rt.cpan.org/NoAuth/Bug.html?id=12882
From: mark [...] summersault.com
Download (untitled) / with headers
text/plain 1.2k
On Fri May 13 11:07:08 2005, guest wrote: Show quoted text
> The ->uri method of WWW::Mechanize does not show the correct URL if > the agent was redirected. However, using the ->uri method of the > underlying HTTP::Request object shows the correct output. > Here's a sample script. > > use WWW::Mechanize; > $agent = WWW::Mechanize->new; > $agent->get("http://bbbike.de"); > warn $agent->uri; # the URL stays the same > warn $agent->response->request->uri; # the correct redirected URL > > Regards, > Slaven
This bug is important to fix. When I arrived to here to see if it was reported, I found three dupe bug reports already filed for it, with some additional "me too" comments in them. Here's a patch against SVN head which fixes it and passes the test suite (roughly corresponds to 1.18). A test for it obviously be a nice addition. --- lib/WWW/Mechanize.pm (revision 2478) +++ lib/WWW/Mechanize.pm (working copy) @@ -424,7 +424,10 @@ =cut -sub uri { my $self = shift; return $self->{uri}; } +sub uri { + my $self = shift; + return $self->response->request->uri->as_string; +} sub res { my $self = shift; return $self->{res}; } sub response { my $self = shift; return $self->{res}; } sub status { my $self = shift; return $self->{status}; }
Download (untitled) / with headers
text/plain 225b
I'd rather see it return a URI object (omit the "->as_string"). In fact, that's one of the things I've done in the subclass of WWW::Mechanize that I use. URI objects stringify as URLs anyway, so it shouldn't break anything.


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.