Subject: | HTTPS Broken |
When requesting HTTPS URI's, only the first 4 responses are successful.
There is a workaround though ... Protocol => 'HTTP/1.0'
Subject: | poe_https.pl |
#!/usr/bin/perl -w
#
# PoCo::Client::HTTP ... broken HTTPS
#
use strict;
use Data::Dumper;
use HTTP::Request;
use POE qw( Component::Client::HTTP );
use constant ME => (0 .. ARG0-1);
use constant MAIN_ALIAS => 'main';
use constant UA_ALIAS => 'ua';
use constant STOCKS =>
qw( AEO AG BBL BCE BMR C CASY CBI CBRL CLP CLWR CNQR EDU EWA EWH FNF GDI
HIG HLTH HME IBB JCG KB LTD MFA NNN RMBS SHLD SNH SUSQ TIF TNB
UBS VMC YHOO AAPL IBM INTC HP CSCO NVDA BAC GS );
POE::Session->create
( inline_states =>
{ _start => \&start,
receive_data => \&receive_data,
}
);
POE::Kernel->run();
exit;
#----------------------------------------
sub start {
$_[KERNEL]->alias_set( MAIN_ALIAS );
POE::Component::Client::HTTP->spawn
( Alias => UA_ALIAS,
# Protocol => 'HTTP/1.0',
Timeout => 10,
FollowRedirects => 1,
);
foreach my $sym (STOCKS)
{ request_https_data( @_[(ME)], $sym ); }
}
sub request_https_data {
my $sym = $_[ARG0];
my $url = 'https://moneycentral.msn.com/detail/stock_quote?'.
"Symbol=$sym&getquote=Get+Quote";
my $req = HTTP::Request->new( GET => $url );
$req->header( x_sym => $sym );
$_[HEAP]{buf}{$sym} = '';
$_[KERNEL]->post( UA_ALIAS, 'request', 'receive_data', $req );
}
sub receive_data {
my ($request_packet, $response_packet) = @_[ARG0, ARG1];
my $req_obj = $request_packet->[0];
my $sym = $req_obj->header( 'x_sym' );
my $resp_obj = $response_packet->[0];
my $new_chunk = $resp_obj->decoded_content();
return if ! $new_chunk;
my $data = $new_chunk;
my @lines = split /<li /, $data;
my $lines = @lines + 0;
print "<$sym> ".length($data)." bytes; $lines lines\n";
print $data."\n" if $sym =~ /^GS/i;
}