+ Can add userinfo in proxypac url (will be used to auth on proxy) (Fix #263)

This commit is contained in:
garnier-quentin 2016-01-11 20:10:31 +01:00
parent 18318462c4
commit c0c8947f93
1 changed files with 6 additions and 3 deletions

View File

@ -153,10 +153,11 @@ sub set_proxy {
if (defined($options{request}->{proxypac}) && $options{request}->{proxypac} ne '') {
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'HTTP::ProxyPAC',
error_msg => "Cannot load module 'HTTP::ProxyPAC'.");
my $pac;
my ($pac, $pac_uri);
eval {
if ($options{request}->{proxypac} =~ /^(http|https):\/\//) {
$pac = HTTP::ProxyPAC->new(URI->new($options{request}->{proxypac}));
$pac_uri = URI->new($options{request}->{proxypac});
$pac = HTTP::ProxyPAC->new($pac_uri);
} else {
$pac = HTTP::ProxyPAC->new($options{request}->{proxypac});
}
@ -167,7 +168,9 @@ sub set_proxy {
}
my $res = $pac->find_proxy($options{url});
if (defined($res->direct) && $res->direct != 1) {
$self->{ua}->proxy(['http', 'https'], $res->proxy);
my $proxy_uri = URI->new($res->proxy);
$proxy_uri->userinfo($pac_uri->userinfo) if (defined($pac_uri->userinfo));
$self->{ua}->proxy(['http', 'https'], $proxy_uri->as_string);
}
}
if (defined($options{request}->{proxyurl}) && $options{request}->{proxyurl} ne '') {