Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Good day fellow monks,

I have experienced very weird thing yesterday. I am using both Windows and Linux and this program (below) doesn't work on both with the first URL (www.tabonline.co.za). However this URL opens fine if I use LWP or Firefox for instance... Please help! Your help will be highly appreciated.

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 AN +D 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, $r +esponse_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();

I get from this code on Win32 406 Not Acceptable, and on Linux 400 Bad request... The weird thing is that from time to time - randomly it works... - Both on Win32 and Linux :( My Request is formed right... I did dump both the request and response - for both URLs... If I don't use HTTPS - I don't have this problem at all. Looks like when wrapped with POCO::SSLify something bad happens. The responses on windows look like this:
$VAR1 = bless( { '_content' => '<html> <HEAD><TITLE>Error: Not Acceptable</TITLE></HEAD> <BODY> <H1>Error: Not Acceptable</H1> Response larger than MaxSize - 1 </BODY> </HTML> ', '_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-a +gent' => 'POE-Component-Client-HTTP/0.82 (perl; N; POE; en; rv:0.8200 +00)', 'accept +-encoding' => 'gzip', 'host' +=> 'www.tabonline.co.za' }, 'HTTP: +:Headers' ), '_method' => 'GET' }, 'HTTP::Request' ) }, 'HTTP::Response' );

Now the LWP one:
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;

Works just fine...

In reply to SSL & POCO::CLIENT::HTTP by avo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2024-04-18 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found