Permalink
Browse files

Merge pull request #6 from mdklapwijk/patch-realserver-support

patch-realserver-support
  • Loading branch information...
2 parents e7b7515 + 931e50f commit 0ba2ac593a678a503b4e8fb2a375b3475000640f @sni committed Sep 24, 2013
Showing with 16 additions and 1 deletion.
  1. +1 −0 Webinject/MYMETA.json
  2. +1 −0 Webinject/MYMETA.yml
  3. +1 −0 Webinject/Makefile.PL
  4. +13 −1 Webinject/lib/Webinject.pm
View
@@ -41,6 +41,7 @@
"HTTP::Request::Common" : "0",
"LWP" : "0",
"Time::HiRes" : "0",
+ "URI" : "0",
"XML::Parser" : "0",
"XML::Simple" : "0",
"perl" : "5.006"
View
@@ -27,6 +27,7 @@ requires:
HTTP::Request::Common: 0
LWP: 0
Time::HiRes: 0
+ URI: 0
XML::Parser: 0
XML::Simple: 0
perl: 5.006
View
@@ -20,6 +20,7 @@ requires 'Crypt::SSLeay' => 0;
requires 'XML::Parser' => 0;
requires 'Error' => 0;
requires 'File::Temp' => 0;
+requires 'URI' => 0;
install_script 'bin/webinject.pl';
View
@@ -20,6 +20,7 @@ use strict;
use warnings;
use Carp;
use LWP;
+use URI;
use HTTP::Request::Common;
use HTTP::Cookies;
use XML::Simple;
@@ -333,6 +334,15 @@ sub _run_test_case {
$case->{$key} = $self->_convertbackxmlresult($case->{$key});
}
+ # replace host with realserverip in url and add http host header to useragent
+ if($self->{'config'}->{'realserverip'})
+ {
+ my($uri)=URI->new($case->{url});
+ my($host)=$uri->host();
+ $useragent->default_header('Host' => $uri->host());
+ $case->{url}=~s/$host/$self->{'config'}->{'realserverip'}/;
+ }
+
if( $self->{'gui'} ) { $self->_gui_tc_descript($case); }
push @{$case->{'messages'}}, { 'html' => "<td>" }; # HTML: open table column
@@ -634,6 +644,7 @@ sub _set_defaults {
'reporttype' => 'standard',
'output_dir' => './',
'nooutput' => undef,
+ 'realserverip' => '',
'baseurl' => '',
'baseurl1' => '',
'baseurl2' => '',
@@ -1318,7 +1329,7 @@ sub _read_config_xml {
foreach (@configlines) {
for my $key (
- qw/baseurl baseurl1 baseurl2 gnuplot proxy timeout output_dir
+ qw/realserverip baseurl baseurl1 baseurl2 gnuplot proxy timeout output_dir
globaltimeout globalhttplog standaloneplot max_redirect
break_on_errors useragent/
)
@@ -1495,6 +1506,7 @@ sub _convertbackxml {
$string =~ s~{AMPERSAND}~&~gmx;
$string =~ s~{LESSTHAN}~<~gmx;
$string =~ s~{TIMESTAMP}~$timestamp~gmx;
+ $string =~ s~{REALSERVERIP}~$self->{'config'}->{realserverip}~gmx;
$string =~ s~{BASEURL}~$self->{'config'}->{baseurl}~gmx;
$string =~ s~{BASEURL1}~$self->{'config'}->{baseurl1}~gmx;
$string =~ s~{BASEURL2}~$self->{'config'}->{baseurl2}~gmx;

0 comments on commit 0ba2ac5

Please sign in to comment.