Skip to content

Commit

Permalink
Fix reading response code
Browse files Browse the repository at this point in the history
  • Loading branch information
HavrilaJ committed Apr 17, 2023
1 parent a61c46c commit c947b74
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pakiti-client
Original file line number Diff line number Diff line change
Expand Up @@ -371,19 +371,18 @@ sub encrypt_report ($) {
sub https {
my ($url, $report) = @_;
my($ua, $response);
my($code,$body);
eval { require LWP::UserAgent; LWP::UserAgent->import; };
if ($@) {
if ($Option{"disable-tls-checks"}) {
($code,$body) = `curl -sik -X POST $url -d "$report"` =~m{\A\S+ (\d+) .*?\r?\n\r?\n(.*)}s;
if ($Option{"disable-tls-checks"}) {
$response = `curl -sik -o /dev/null -w "%{http_code}" -X POST $url -d "$report"`;
} else {
($code,$body) = `curl -si -X POST $url -d "$report"` =~m{\A\S+ (\d+) .*?\r?\n\r?\n(.*)}s;
$response = `curl -si -o /dev/null -w "%{http_code}" -X POST $url -d "$report"`;
}
if ($body =~ m/200 OK/) {
if ($response == "200") {
print(STDERR "report successfully sent\n") if -t STDERR;
print "OK\n";
} else {
die($body);
die($response);
}
} else {
my $ua = LWP::UserAgent->new();
Expand Down

0 comments on commit c947b74

Please sign in to comment.