Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Re: LWP::UserAgent destroys $response->content >:{

by iguanodon (Priest)
on May 22, 2003 at 14:23 UTC ( #260068=note: print w/replies, xml ) Need Help??

in reply to Re: LWP::UserAgent destroys $response->content >:{
in thread LWP::UserAgent destroys $response->content >:{

I don't think this is an LWP::UserAgent problem. It may be something specific to the Linksys "web server". I can grab the status page from my Netgear router with no problem using this code:
#!/usr/local/bin/perl use strict; use warnings; $| = 1; use LWP::UserAgent; use HTTP::Request::Common qw(GET POST); use HTTP::Cookies; my $user = 'user'; my $pass = 'pass'; my $cookie_jar = HTTP::Cookies->new(file => '/tmp/cookie_jar', AutoSav +e => 1); my $ua = LWP::UserAgent->new(); $ua->cookie_jar($cookie_jar); my $req = GET ''; $req->authorization_basic($user, $pass); my $response = $ua->request($req); print $response->code . ' ' . $response->message . "\n"; my $content = $response->content; if ($content) { print $content; } else { print 'No content!'; } print "\n";

Can you give this a try (after adjusting for your environment) and see if you still get the 500 error?

Replies are listed 'Best First'.
Re: Re: Re: LWP::UserAgent destroys $response->content >:{
by SPotter (Initiate) on May 22, 2003 at 18:07 UTC
    I added the cookie jar (relavant code below)
    (I didn't spot any other functional difference)

    Same Result :{

    So, it looks like I'll have to dispense with the
    $response = $ua->request($request);
    and replace it with low level code - merde! ;)

    use AppConfig; use File::Basename; use Getopt::Long; use HTML::Form; use HTTP::Request::Common; use HTML::TreeBuilder; use HTTP::Cookies; use LWP::DebugFile ('+'); use LWP::UserAgent; use Pod::Usage; use URI::file; . . my $cookie_jar = HTTP::Cookies->new(file => '/tmp/cookie_jar', AutoSav +e => 1); my $ua; . . $ua = LWP::UserAgent->new(); $ua->agent('Mozilla/4.0'); $ua->max_size('5000'); $ua->cookie_jar($cookie_jar); . . $ua->credentials($netloc, $realm, $userid, $passwd); . . $request = HTTP::Request->new(GET => ""); $response = $ua->request($request); #$response = $ua->request($request,"rspfile.html"); if ($response->is_error) { my $string; print "Error: " . $response->status_line . "\n"; print $response->error_as_HTML; $string = $response->as_string; die "$string\n"; } . .

    Steve Potter

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://260068]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2018-05-27 16:06 GMT
Find Nodes?
    Voting Booth?