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}; }