Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
use keep alive as long as we don't use https over a proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Nov 18, 2013
1 parent a4df2dc commit cd7324f
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions Webinject/lib/Webinject.pm
Expand Up @@ -247,7 +247,7 @@ sub engine {
$repeat = $xmltestcases->{repeat};
}

my $useragent = $self->_get_useragent();
my $useragent = $self->_get_useragent($xmltestcases->{case});

for my $run_nr (1 .. $repeat) {

Expand Down Expand Up @@ -321,7 +321,7 @@ sub _run_test_case {
$case->{'iscritical'} = 0;
$case->{'messages'} = [];

$useragent = $self->_get_useragent() unless defined $useragent;
$useragent = $self->_get_useragent({1 => $case}) unless defined $useragent;

# don't do this if monitor is disabled in gui
if($self->{'gui'} and $self->{'monitorenabledchkbx'} ne 'monitor_off') {
Expand Down Expand Up @@ -581,10 +581,19 @@ sub _run_test_case {

################################################################################
sub _get_useragent {
my($self) = @_;

# construct LWP object
my $useragent = LWP::UserAgent->new(); # do not set keepalive here, it breaks ssl proxy support
my($self, $testcases) = @_;

# keepalive is required for ntml authentication but breaks
# https proxy support, so try determince which one we need
my $keepalive = 1;
if($testcases and $self->{'config'}->{'proxy'}) {
for my $nr (keys %{$testcases}) {
if($testcases->{$nr}->{'url'} =~ m/^https/gmx) {
$keepalive = 0;
}
}
}
my $useragent = LWP::UserAgent->new(keep_alive=>$keepalive);

# store cookies in our LWP object
my($fh, $cookietempfilename) = tempfile(undef, UNLINK => 1);
Expand Down

0 comments on commit cd7324f

Please sign in to comment.