diff --git a/apps/protocols/http/mode/expectedcontent.pm b/apps/protocols/http/mode/expectedcontent.pm index 4753f2776..17a689326 100644 --- a/apps/protocols/http/mode/expectedcontent.pm +++ b/apps/protocols/http/mode/expectedcontent.pm @@ -47,6 +47,7 @@ sub new { "proxyurl:s" => { name => 'proxyurl' }, "expected-string:s" => { name => 'expected_string' }, "timeout:s" => { name => 'timeout' }, + "no-follow" => { name => 'no_follow', }, "ssl:s" => { name => 'ssl', }, "cert-file:s" => { name => 'cert_file' }, "key-file:s" => { name => 'key_file' }, @@ -151,6 +152,10 @@ Specify password for basic authentification (Mandatory if --credentials is speci Threshold for HTTP timeout (Default: 5) +=item B<--no-follow> + +Do not follow http redirect + =item B<--ssl> Specify SSL version (example : 'sslv3', 'tlsv1'...) diff --git a/apps/protocols/http/mode/responsetime.pm b/apps/protocols/http/mode/responsetime.pm index 2c442043f..755f9affd 100644 --- a/apps/protocols/http/mode/responsetime.pm +++ b/apps/protocols/http/mode/responsetime.pm @@ -49,6 +49,7 @@ sub new { "warning:s" => { name => 'warning' }, "critical:s" => { name => 'critical' }, "timeout:s" => { name => 'timeout' }, + "no-follow" => { name => 'no_follow', }, "ssl:s" => { name => 'ssl' }, "cert-file:s" => { name => 'cert_file' }, "key-file:s" => { name => 'key_file' }, @@ -167,6 +168,10 @@ Proxy URL if any Threshold for HTTP timeout (Default: 5) +=item B<--no-follow> + +Do not follow http redirect + =item B<--ssl> Specify SSL version (example : 'sslv3', 'tlsv1'...) diff --git a/centreon/plugins/http.pm b/centreon/plugins/http.pm index ef0509243..ff9b96b9e 100644 --- a/centreon/plugins/http.pm +++ b/centreon/plugins/http.pm @@ -158,13 +158,17 @@ sub request { $self->check_options(request => $request_options); if (!defined($self->{ua})) { - $self->{ua} = LWP::UserAgent->new(keep_alive => 1, protocols_allowed => ['http', 'https'], timeout => $request_options->{timeout}, - requests_redirectable => [ 'GET', 'HEAD', 'POST' ]); + $self->{ua} = LWP::UserAgent->new(keep_alive => 1, protocols_allowed => ['http', 'https'], timeout => $request_options->{timeout}); if (defined($request_options->{cookies_file})) { $self->{ua}->cookie_jar(HTTP::Cookies->new(file => $request_options->{cookies_file}, autosave => 1)); } } + if (defined($request_options->{no_follow})) { + $self->{ua}->requests_redirectable(undef); + } else { + $self->{ua}->requests_redirectable([ 'GET', 'HEAD', 'POST' ]); + } if (defined($request_options->{http_peer_addr})) { push @LWP::Protocol::http::EXTRA_SOCK_OPTS, PeerAddr => $request_options->{http_peer_addr}; }