fix csv encoding (#2696)
This commit is contained in:
parent
f4cdaca5c1
commit
5745b4649e
|
@ -218,7 +218,6 @@ sub request_api_csv {
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->settings();
|
$self->settings();
|
||||||
|
|
||||||
$self->{output}->output_add(long_msg => "URL: '" . $options{full_url} . "'", debug => 1);
|
$self->{output}->output_add(long_msg => "URL: '" . $options{full_url} . "'", debug => 1);
|
||||||
|
|
||||||
my $content = $self->{http}->request(%options);
|
my $content = $self->{http}->request(%options);
|
||||||
|
@ -240,16 +239,10 @@ sub request_api_csv {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $decoded;
|
if (!centreon::plugins::misc::minimal_version(Text::CSV->VERSION, '1.31')) {
|
||||||
eval {
|
$content =~ s/^\x{feff}//; # patched in Test-CSV 1.31
|
||||||
$decoded = decode('UTF-8', $content);
|
|
||||||
};
|
|
||||||
if ($@) {
|
|
||||||
$self->{output}->output_add(long_msg => $content, debug => 1);
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Cannot decode response: $@");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
}
|
||||||
$decoded =~ s/^\x{feff}//;
|
my $decoded = encode('UTF-8', $content);
|
||||||
|
|
||||||
my @rows;
|
my @rows;
|
||||||
eval {
|
eval {
|
||||||
|
@ -261,7 +254,6 @@ sub request_api_csv {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
$self->{output}->output_add(long_msg => $content, debug => 1);
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Cannot parse csv response: $@");
|
$self->{output}->add_option_msg(short_msg => "Cannot parse csv response: $@");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue