use strict;
use POE;
use POE::Component::Client::HTTP; # WRAPPED IN POCO::CLIENT::SSLIFY
use HTTP::Request::Common qw(GET POST);
my $url = "https://www.tabonline.co.za/"; # DOESN'T WORK IN WINDOWS AND LINUX - WORKS FINE IN A BROWSER AND LWP
# my $url = "https://www.helsinki.fi/"; # WORKS FINE IN THIS EXAMPLE
POE::Component::Client::HTTP->spawn
( Alias => 'uapar',
Timeout => 200,
FollowRedirects => 2,
);
POE::Session->create
( inline_states =>
{ _start => sub {
my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
my $request = HTTP::Request->new(
GET => $url, []
);
$kernel->post( uapar => request => got_response => $request );
},
got_response => sub {
my ( $kernel, $heap, $request_packet, $response_packet ) = @_[ KERNEL, HEAP, ARG0, ARG1 ];
my $http_request = $request_packet->[0];
my $http_response = $response_packet->[0];
my $response_string = $http_response->as_string();
print $response_string;
},
},
);
$poe_kernel->run();
####
$VAR1 = bless( {
'_content' => '
Error: Not Acceptable
Error: Not Acceptable
Response larger than MaxSize - 1
',
'_rc' => 406,
'_headers' => bless( {}, 'HTTP::Headers' ),
'_msg' => undef,
'_request' => bless( {
'_protocol' => 'HTTP/1.1',
'_content' => '',
'_uri' => bless( do{\(my $o = 'https://www.tabonline.co.za/')}, 'URI::https' ),
'_headers' => bless( {
'user-agent' => 'POE-Component-Client-HTTP/0.82 (perl; N; POE; en; rv:0.820000)',
'accept-encoding' => 'gzip',
'host' => 'www.tabonline.co.za'
}, 'HTTP::Headers'
),
'_method' => 'GET'
}, 'HTTP::Request' )
}, 'HTTP::Response' );
##
##
use LWP;
my $url = 'https://www.tabonline.co.za/';
my $browser = LWP::UserAgent->new;
my $response = $browser->get($url);
die "Error at $url\n ", $response->status_line, "\n Aborting"
unless $response->is_success;
print "It worked! I got that ",
$response->content_type, " document!\n";
print $response->content;