script/simple_post.pl untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 35 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use lib '../lib';
5 use LightTCP::SSLclient;
6  
7 my $client = LightTCP::SSLclient->new(timeout => 30);
8 my ($ok, $errors, $debug, $code) = $client->connect('reqbin.com', 443);
9  
10 unless ($ok) {
11 die "Connect failed: @$errors";
12 }
13  
14 my $payload = '{"name":"test","value":123}';
15  
16 ($ok, $errors, $debug, $code) = $client->request(
17 'POST',
18 '/echo/post/json',
19 host => 'reqbin.com',
20 payload => $payload,
21 headers => {
22 'Content-Type' => 'application/json',
23 },
24 );
25  
26 unless ($ok) {
27 die "Request failed: @$errors";
28 }
29  
30 my ($status, $state, $headers, $body) = $client->response();
31  
32 print "Status: $status $state\n";
33 print "Response:\n";
34 print $body;
35 print "\n";
36  
37 $client->close();