Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation


by avo (Pilgrim)
on Jun 07, 2008 at 11:40 UTC ( #690826=perlquestion: print w/replies, xml ) Need Help??

avo has asked for the wisdom of the Perl Monks concerning the following question:

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 ( 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 = ""; # DOESN'T WORK IN WINDOWS AN +D LINUX - WORKS FINE IN A BROWSER AND LWP # my $url = ""; # 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 = +'')}, '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' +=> '' }, 'HTTP: +:Headers' ), '_method' => 'GET' }, 'HTTP::Request' ) }, 'HTTP::Response' );

Now the LWP one:
use LWP; my $url = ''; 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...

Replies are listed 'Best First'.
by rcaputo (Chaplain) on Jun 07, 2008 at 17:19 UTC

    Works fine here. Are you using POE::Component::Client::HTTP 0.84?

    HTTP/1.1 200 OK
    Cache-Control: private
    Date: Sun, 08 Jun 2008 00:16:07 GMT
    Server: Microsoft-IIS/6.0
    Content-Length: 498
    Content-Type: text/html; charset=utf-8
    X-AspNet-Version: 2.0.50727
    X-Powered-By: ASP.NET
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "">
    <HTML><HEAD><TITLE>Redirect to news site</TITLE>
    <link href="StyleSheets.css" rel="stylesheet" type="text/css" />
    <META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">

    Loading . . .
    <Script Language="JavaScript"> top.location="" </script> </BODY> </HTML>

      I wasn't using 0.84 which has solved the issue on linux. But on Windows (Using ActiveState Perl 5.10) I have now a bigger issue. The SSLify module can not set the socket to be blocking using the IO::Handle's blocking(1) method (&Set_Blocking). I see that there is a work around on internet of dealing with blocking sockets and win 32 which is working somehow on ActiveState Perl 5.10 (here). But I am not sure how to apply this patch... Can you help me please. Please try using in the test. I gave it a shot but after overriding the socket blocking mode like that I am now getting Bad Request "incomplete response" ... Looks like doesn't read anything from this socket. Funny enough looks like from time to time it does. Very strange. Please help!
      Herewith a hint on the problem... experienced in a different environment - same issue...

        Please submit your information to POE::Component::Client::HTTP's request tracker at There are a few benefits (and few, if any drawbacks) from using the official but tracker: (a) Requests stay organized and in a place I'm sure to find them later. (b) Your request isn't lost in a sea of web pages. (c) You will be notified by e-mail when the status of your request changes. (d) Possibly some other stuff, but it's all good.

        The Perl community offers as a resource for CPAN authors, and the users who love (and, to be honest, hate) their modules. Thanks for working with us to make Perl and CPAN a better place for tomorrow.

by starbolin (Hermit) on Jun 07, 2008 at 21:04 UTC

    The errors could be triggered by bad HTML code. The page delivered contains XHTML tags but the doctype is given as HTML 4.01. It would seem the site given is a poor choice of dataset. Though I'm not sure how this would affect a simple GET operation but, at least, my validator is complaining about extra strings inside tags so could that be the reason for POE complaining: Response larger than MaxSize - 1

    s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://690826]
Approved by kabeldag
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2022-12-07 23:34 GMT
Find Nodes?
    Voting Booth?

    No recent polls found