| 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( | ||
| 8 | timeout => 30, | ||
| 9 | verbose => 1, | ||
| 10 | ); | ||
| 11 | |||
| 12 | my ($ok, $errors, $debug, $code) = $client->connect('reqbin.com', 443); | ||
| 13 | |||
| 14 | unless ($ok) { | ||
| 15 | die "Connect failed: @$errors"; | ||
| 16 | } | ||
| 17 | |||
| 18 | ($ok, $errors, $debug, $code) = $client->request('GET', '/echo', host => 'reqbin.com'); | ||
| 19 | |||
| 20 | unless ($ok) { | ||
| 21 | die "Request failed: @$errors"; | ||
| 22 | } | ||
| 23 | |||
| 24 | my ($status, $state, $headers, $body) = $client->response(); | ||
| 25 | |||
| 26 | print "=== DEBUG OUTPUT ===\n"; | ||
| 27 | print @$debug; | ||
| 28 | |||
| 29 | print "\n=== ERRORS ===\n"; | ||
| 30 | print @$errors ? @$errors : "(none)\n"; | ||
| 31 | |||
| 32 | print "\n=== RESPONSE ===\n"; | ||
| 33 | print "Status: $status $state\n"; | ||
| 34 | print "Body length: " . length($body) . " bytes\n"; | ||
| 35 | |||
| 36 | $client->close(); |