I appreciate the LWP cookbook solution, which mentions a subclass solution with passing a link to lwp-request.
the wise pearl monk once said: ole subclasses of the LWP subclass :: UserAgent tag
package AgentP; use base 'LWP::UserAgent'; sub _agent { "Mozilla/8.0" } sub get_basic_credentials { return 'admin', 'password'; } package main; use AgentP; my $agent = AgentP->new; my $response = $agent->get( 'http://127.0.0.1/hideout.html' ); print $agent->agent();
the record has been revised with some bad humor, a usage statement, an _agent override, and an updated agent print line.
Bonus material for those interested: HTTP basic auth with overriding get_basic_credentials, as most people come up with a solution for the subclass. Methods are sacred or something like that; but it scratches the itch, doesn't it?
source share