script/simple_redirect.pl untested

filter: Statementstmt 0.0% 0 / 28 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 38 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(
8 timeout => 30,
9 follow_redirects => 1,
10 max_redirects => 5,
11 );
12  
13 my ($ok, $errors, $debug, $code) = $client->connect('reqbin.com', 443);
14  
15 unless ($ok) {
16 die "Connect failed: @$errors";
17 }
18  
19 my ($status, $state, $headers, $body, $resp_errors, $resp_debug, $resp_code, $history)
20 = $client->request_with_redirects('GET', '/echo', host => 'reqbin.com');
21  
22 print "Final status: $status $state\n";
23 print "Redirects followed: " . scalar(@$history) . "\n";
24  
25 if (@$history) {
26 print "\n--- Redirect chain ---\n";
27 for my $r (@$history) {
28 print "$r->{code}: $r->{from}\n";
29 print " -> $r->{to}\n";
30 }
31 }
32  
33 print "\n--- Response body preview ---\n";
34 print substr($body, 0, 300);
35 print "...\n" if length($body) > 300;
36  
37 $client->close();