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).

--
if ( 1 ) { $postman->ring() for (1..2); }

In reply to WWW::Mechanize trouble reading a text/plain file on a server by gargle

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.