Subject: | _check_links_status() looses cookie_jar |
In _check_links_status, $self->clone() is called to clone the mechanize
object. Unfortunately clone() does not copy the cookie_jar over to the
clone()'d object.
This causes problems for me because I am using cookies for
authentication, and I want to set a cookie in the mechanize object
before calling $mech->links_ok(). If I do not have the cookie set, I
get "403" responses for pages that require authentication, which causes
links_ok() to (correctly) report that some links were not valid.
This should probabably be fixed in LWP::UserAgent, but a workaround is
to just add this line in _check_links_status() after the clone() call:
$mech->{cookie_jar} = $self->cookie_jar; # clone() drops cookie_jar
I am going to report the problem with clone() to the LWP maintainer as
well. I will leave it up to you if you want to do anything to work
around this problem in Test::WWW::Mechanize or not :).
I am not sure if the LWP maintainer will do anything about this or not.
Regards,
Michael Schout