in reply to Re^3: LWP handlers examples?
in thread LWP handlers examples?

This code works OK, even if I change it to use Mechanize instead of UserAgent, but does not work inside my original program... remove_handler() removes all available handlers, including the internal, ignoring %matchspec.

print "Hdl1: ".join(" ",$mech->handlers('response_header', $mech->re +sponse()))."\n"; $mech->add_handler(response_header => \&response, owner => "vitoco") +; print "Hdl2: ".join(" ",$mech->handlers('response_header', $mech->re +sponse()))."\n"; $mech->add_header('If-Modified-Since', time2str($current)) if $curre +nt; my $resp = $mech->get($url, ':content_file' => "$file.tmp"); $mech->delete_header('If-Modified-Since') if $current; $mech->remove_handler('response_header', owner => "vitoco"); print "Hdl3: ".join(" ",$mech->handlers('response_header', $mech->re +sponse()))."\n"; print "Hdl4: ".join(" ",$mech->handlers('response_header', $resp))." +\n";
Hdl1: HASH(0x1f87dbc) Hdl2: HASH(0x1f87dbc) HASH(0x1f9d174) Hdl3: Hdl4:

I changed de example to use :content_file, and stil works, so it is not that. Note that Hdl3 and Hdl4 uses different response objects (or the same, obtained from different ways).