From b544cd43c0b842e7cab366276540db0d3b078e8c Mon Sep 17 00:00:00 2001 From: qgarnier Date: Mon, 2 May 2022 16:41:43 +0200 Subject: [PATCH] (core) add option to change default http backend (#3630) --- centreon-plugins/centreon/plugins/http.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/centreon/plugins/http.pm b/centreon-plugins/centreon/plugins/http.pm index c0c2c2808..9818942f6 100644 --- a/centreon-plugins/centreon/plugins/http.pm +++ b/centreon-plugins/centreon/plugins/http.pm @@ -34,7 +34,7 @@ sub new { 'proxyurl:s' => { name => 'proxyurl' }, 'proxypac:s' => { name => 'proxypac' }, 'insecure' => { name => 'insecure' }, - 'http-backend:s' => { name => 'http_backend', default => 'lwp' } + 'http-backend:s' => { name => 'http_backend' } }); $options{options}->add_help(package => __PACKAGE__, sections => 'HTTP GLOBAL OPTIONS'); } @@ -53,6 +53,8 @@ sub new { ); $self->{backend_curl} = centreon::plugins::backend::http::curl->new(%options); + $self->{default_backend} = defined($options{default_backend}) && $options{default_backend} ne '' ? + $options{default_backend} : 'lwp'; $self->{output} = $options{output}; $self->{options} = { proto => 'http', @@ -92,7 +94,7 @@ sub remove_header { sub check_options { my ($self, %options) = @_; - $options{request}->{http_backend} = 'lwp' + $options{request}->{http_backend} = $self->{default_backend} if (!defined($options{request}->{http_backend}) || $options{request}->{http_backend} eq ''); $self->{http_backend} = $options{request}->{http_backend}; if ($self->{http_backend} !~ /^\s*lwp|curl\s*$/i) {