Net-DRI
view release on metacpan or search on metacpan
lib/Net/DRI/Transport/HTTP.pm view on Meta::CPAN
$ua->agent(sprintf('Net::DRI/%s Net::DRI::Transport::HTTP/%s ',$Net::DRI::VERSION,$VERSION)); ## the final space triggers LWP::UserAgent to add its own string
$ua->cookie_jar({}); ## Cookies needed by some registries, like .PL (how strange !)
## Now some security settings
$ua->max_redirect(0);
$ua->parse_head(0);
$ua->protocols_allowed(['http','https']);
$ua->timeout($self->timeout()) if $self->timeout(); ## problem with our own alarm ?
$t{ua}=$ua;
$t{local_host}=$opts{local_host} if (exists($opts{local_host}) && $opts{local_host});
$t{setenv}=0;
foreach my $k (map { lc } @HTTPS_ENV) ## Backport this stuff to other Transport modules in order to handle multiple differents sets of env values ?
{
next unless (exists($opts{$k}) && defined($opts{$k}));
$t{setenv}=1;
$t{$k}=$opts{$k};
}
$t{verify_response}=$opts{verify_response} if (exists($opts{verify_response}) && defined($opts{verify_response}) && (ref($opts{verify_response}) eq 'CODE'));
$self->{transport}=\%t;
$t{pc}->init($self) if $t{pc}->can('init');
$self->open_connection($ctx); ## noop for registries without login, will properly setup has_state()
return $self;
}
lib/Net/DRI/Transport/HTTP.pm view on Meta::CPAN
sub _http_send
{
my ($self,$count,$tosend,$phase)=@_;
$phase=2 unless defined($phase); ## Phase 2 = normal operations (1=greeting+login, 3=logout)
my $t=$self->transport_data();
## Having two lines put the warnings away. This module is loaded by LWP::UserAgent anyway.
@LWP::Protocol::http::EXTRA_SOCK_OPTS=();
@LWP::Protocol::http::EXTRA_SOCK_OPTS=( LocalAddr => $t->{local_host} ) if exists($t->{local_host});
if ($t->{setenv})
{
foreach my $k (map { lc } @HTTPS_ENV)
{
delete($ENV{uc($k)});
next unless exists($t->{$k});
$ENV{uc($k)}=$t->{$k};
}
}
## Content-Length is automatically computed and added during the request() call, no need to do it before
( run in 0.684 second using v1.01-cache-2.11-cpan-13bb782fe5a )