Subject: | Replace _do_request |
Cc: | Philippe.Bruhat [...] free.fr |
From: Philippe 'BooK' Bruhat <Philippe.Bruhat@free.fr>
To: andy@petdance.com
Subject: Problem with WWW::Mechanize test suite
In fact, if I understand LWP::UserAgent correctly, a WWW::Mechanize
object probably needs to do away with the _do_request() method, and simply
overload the send_request() method from LWP::UserAgent:
sub send_request {
my $self = shift;
my $request = shift;
foreach my $h ( keys %WWW::Mechanize::headers ) {
$request->header( $h => $WWW::Mechanize::headers{$h} );
}
$self->{res} = $self->SUPER::send_request( $request, @_ );
$self->{status} = $self->{res}->code;
$self->{base} = $self->{res}->base;
$self->{ct} = $self->{res}->content_type || "";
$self->{content} = $self->{res}->content;
if ( $self->{ct} eq 'text/html' ) {
$self->{forms} =
[ HTML::Form->parse( $self->{content}, $self->{res}->base ) ];
$self->{form} = $self->{forms}->[0] if @{ $self->{forms} };
$self->{links} = $self->extract_links();
}
return $self->{res};
}
This way, the usual request(), simple_request() and send_request() methods
will update the WWW::Mechanize specific data, so that they'll be available
for any request.