Permalink
Browse files

use keep alive as long as we don't use https over a proxy

  • Loading branch information...
1 parent a4df2dc commit cd7324fcaf8806e8d5bc9b107f3dc2663850a476 @sni committed Nov 18, 2013
Showing with 15 additions and 6 deletions.
  1. +15 −6 Webinject/lib/Webinject.pm
View
@@ -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) {
@@ -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') {
@@ -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);

0 comments on commit cd7324f

Please sign in to comment.