gargle has asked for the wisdom of the Perl Monks concerning the following question:
My fellow monks,
A stupid question perhaps, this stuff is bugging me for a while now. I tried the usual, I read the docs, I searched perlmonks, I googled... but to no avail.
I try to access a log file on a testlink server but all I get is an empty string if I just do a 'get'. The weird thing is that if I fetch the log file in a temporary file I can read the file.
This doesn't work:
$mech->get( $TLKAUDITSURL ); print $mech->content();
The headers I get in the response object are:
$VAR1 = bless( { '_protocol' => 'HTTP/1.1', '_content' => '', '_rc' => 200, '_headers' => bless( { 'connection' => 'close', 'client-response-num' => 1, 'last-modified' => 'Tue, 24 Ma +y 2011 06:50:00 GMT', 'accept-ranges' => 'bytes', 'date' => 'Tue, 24 May 2011 07 +:29:55 GMT', 'client-peer' => '10.192.39.90 +:80', 'content-length' => '21097062' +, 'client-date' => 'Tue, 24 May +2011 07:29:57 GMT', 'etag' => '"aa-141ea66-4a3ffff +2d7600"', 'content-type' => 'text/plain' +, 'server' => 'Apache/2.2.15 (Un +ix) PHP/5.3.2' }, 'HTTP::Headers' ), '_msg' => 'OK', '_request' => bless( { '_content' => '', '_uri' => bless( do{\(my $o = +'http://tlk/logs/audits.log')}, 'URI::http' ), '_headers' => bless( { 'user-a +gent' => 'WWW-Mechanize/1.68', 'accept +-encoding' => 'gzip', 'refere +r' => 'http://tlk/logs/audits.log' }, 'HTTP: +:Headers' ), '_method' => 'GET', '_uri_canonical' => $VAR1->{'_ +request'}{'_uri'} }, 'HTTP::Request' ) }, 'HTTP::Response' );
This however does work:
$mech->get( $TLKAUDITSURL, ':content_file' => $TMPAUDITSLOG ); open( FH, '<', $TMPAUDITSLOG ); my @check = <FH>; close FH; foreach my $line (@check) { chomp $line; print $line . "\n"; }
In the info returned I find this as an extra:
'handlers' => { 'response_done' => [ { 'callback' => +sub { "DUMMY" } } ] },
What on earth am I missing? I don't want to use a temp file, I just want to access the log file by means of a simple $mech->content() or something similar (but no call to system or any backticks to invoke wget or curl).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: WWW::Mechanize trouble reading a text/plain file on a server
by Corion (Patriarch) on May 24, 2011 at 08:07 UTC | |
Re: WWW::Mechanize trouble reading a text/plain file on a server
by Anonymous Monk on May 24, 2011 at 08:04 UTC |