libwww-perl
view release on metacpan or search on metacpan
lib/LWP/UserAgent.pm view on Meta::CPAN
}
}
$self->{conn_cache} = $cache;
}
return $old;
}
sub add_handler {
my($self, $phase, $cb, %spec) = @_;
$spec{line} ||= join(":", (caller)[1,2]);
my $conf = $self->{handlers}{$phase} ||= do {
require HTTP::Config;
HTTP::Config->new;
};
$conf->add(%spec, callback => $cb);
}
sub set_my_handler {
my($self, $phase, $cb, %spec) = @_;
$spec{owner} = (caller(1))[3] unless exists $spec{owner};
$self->remove_handler($phase, %spec);
$spec{line} ||= join(":", (caller)[1,2]);
$self->add_handler($phase, $cb, %spec) if $cb;
}
sub get_my_handler {
my $self = shift;
my $phase = shift;
my $init = pop if @_ % 2;
my %spec = @_;
my $conf = $self->{handlers}{$phase};
unless ($conf) {
lib/LWP/UserAgent.pm view on Meta::CPAN
my @h = $conf->find(%spec);
if (!@h && $init) {
if (ref($init) eq "CODE") {
$init->(\%spec);
}
elsif (ref($init) eq "HASH") {
$spec{$_}= $init->{$_}
for keys %$init;
}
$spec{callback} ||= sub {};
$spec{line} ||= join(":", (caller)[1,2]);
$conf->add(\%spec);
return \%spec;
}
return wantarray ? @h : $h[0];
}
sub remove_handler {
my($self, $phase, %spec) = @_;
if ($phase) {
my $conf = $self->{handlers}{$phase} || return;
( run in 0.691 second using v1.01-cache-2.11-cpan-a3c8064c92c )