problem with LWP
mutatedgene
created: 2006-06-02 15:23:04
Hello Perl Monks

okay so i have this problem with using the LWP library.

I have jsut sttarted learning how to use it so im using this very simple program that gets the page of the given url

#!usr/bin/perl

use LWP::Simple;

getprint($ARGV[0]);

exit;

when i run this program it seems to get stuck in an infinite loop. when i ran it using the debugger this was the final error that i got when i just skipped running throught the modules
IO::Socket::connect(/usr/lib/perl5/5.8.0/i386-linux-thread-multi/IO/Socket.pm:121):
121:                    $err = $! || (exists &Errno::ETIMEDOUT ? &Errno::ETIMEDOUT : 1);

so i ran thro the debugger line by line and as suspected it gets stuck in an infinite loop. the following are the lines of code that kept repeating as given by the debugger
im sorry if im being a little too descriptive. just that i really didnt understand whats going on so i jus copied the lines from the terminal
HTTP::Headers::CODE(0x82e8db0)(/usr/lib/perl5/site_perl/5.8.0/HTTP/Headers.pm:59):
59:         for (@header_order) {
  DB<8>

HTTP::Headers::CODE(0x82e8db0)(/usr/lib/perl5/site_perl/5.8.0/HTTP/Headers.pm:60):
60:             my $lc = lc $_;
  DB<8> s

HTTP::Headers::CODE(0x82e8db0)(/usr/lib/perl5/site_perl/5.8.0/HTTP/Headers.pm:61):
61:             $header_order{$lc} = ++$i;
  DB<8> s

HTTP::Headers::CODE(0x82e8db0)(/usr/lib/perl5/site_perl/5.8.0/HTTP/Headers.pm:62):
62:             $standard_case{$lc} = $_;
  DB<8> s

these are the four lines that keep repeating in the debugger. im not able to go beyond this

can anyone tell me what is going on andhow i solve this problem?? plz help!!. will be really grateful!!

Arvind

Edit: [g0n] code tags round output data

Re: problem with LWP
created: 2006-06-02 20:24:43
I ran this prompt>./lwp.pl http://amazon.com and it works fine on OSX:
#!/usr/bin/perl

use strict;
use warnings;
use LWP::Simple;

print get($ARGV[0]);

exit;
Re^2: problem with LWP
created: 2006-06-03 12:11:52
hey ..

thanks.. the problem was with the proxy.. got it corrected with a lil help from the monks at the CB.. thanks for helping!!
Re: problem with LWP
created: 2006-06-02 21:51:50

So, the bit that keeps repeating in the debugger is a red herring, I think. If you take a look at that section of the code, it repeats about 40 or 50 times - it looks like an infinite loop if you step through it in the debugger, but at run time certainly less than a second. Barring an extremely broken Perl, I don't see how that code could be looping infinitely. (It just builds indexes of common HTTP headers... and at module load-time, to boot.)

My wild guess is that the socket issue is closer to the heart of the problem. Is there perhaps a proxy issue? Can you telnet to port 80 from your terminal?

Re^2: problem with LWP
created: 2006-06-03 12:13:03
yeah! u got it bang on!!

it was a proxy issue... got it solved.. thanks a mil for the help!!
Re: problem with LWP
created: 2006-06-03 07:59:22
Try using [cpan://LWP::Debug]. Example
C:\>lwp-request -x http://search.cpan.org/
LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET http://search.cpan.org/
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 689 bytes
LWP::Protocol::collect: read 1696 bytes
LWP::Protocol::collect: read 1231 bytes
LWP::UserAgent::request: Simple response: OK


 
****SNIP****
C:\>
[http://search.cpan.org/author/GAAS/libwww-perl-5.805/bin/lwp-request|lwp-request]

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

perlmonks.org content © perlmonks.org and ercparker, fishbot_v2, mutatedgene, PodMaster

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03