Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

Help on debugging print problem

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


cfaust at doyougot

May 30, 2013, 4:11 AM

Post #1 of 5 (220 views)
Permalink
Help on debugging print problem

Hi,



I have some code I use all the time I use to download a file:



if (-e '/report.pdf') {

open(PDF, '/report.pdf') or die "could not open PDF $!";

binmode PDF;

my $output = do { local $/; <PDF> };

close(PDF);

$r->content_type('application/pdf');

$r->err_headers_out->add('Content-Disposition' =>
'attachment; filename="report.pdf"');

$r->print($output);

}



I've never had a problem before using the above until trying to do it on a
new machine. On that machine every time I still get prompted to download the
file but FF/IE says its only 20 bytes (even though the pdf is 200k on the
file system) and what is downloaded is not what is on the filesystem.



I tried different files, different paths etc with the same results so I
don't think it's a location or permissions issue.



The only thing that gets logged in the attempt is:



TIGHT LOOP!!!: Apache2::RequestRec=SCALAR(0x47e2f78) can't
Apache2::RequestRec::print!



Any ideas how I could further debug that error to find the cause?



TIA!

-Chris


mdon at names

May 30, 2013, 6:11 AM

Post #2 of 5 (203 views)
Permalink
Re: Help on debugging print problem [In reply to]

At a guess, I'd say your new machine is using chunked output, so you might need to add a size header.

Marcus


On 30 May 2013, at 12:11, "Chris Faust" <cfaust [at] doyougot> wrote:

> Hi,
>
> I have some code I use all the time I use to download a file:
>
> if (-e '/report.pdf') {
> open(PDF, '/report.pdf') or die "could not open PDF $!";
> binmode PDF;
> my $output = do { local $/; <PDF> };
> close(PDF);
> $r->content_type('application/pdf');
> $r->err_headers_out->add('Content-Disposition' => 'attachment; filename="report.pdf"');
> $r->print($output);
> }
>
> I've never had a problem before using the above until trying to do it on a new machine. On that machine every time I still get prompted to download the file but FF/IE says its only 20 bytes (even though the pdf is 200k on the file system) and what is downloaded is not what is on the filesystem.
>
> I tried different files, different paths etc with the same results so I don't think it's a location or permissions issue.
>
> The only thing that gets logged in the attempt is:
>
> TIGHT LOOP!!!: Apache2::RequestRec=SCALAR(0x47e2f78) can't Apache2::RequestRec::print!
>
> Any ideas how I could further debug that error to find the cause?
>
> TIA!
> -Chris
>
>


cfaust at doyougot

May 30, 2013, 8:54 AM

Post #3 of 5 (203 views)
Permalink
RE: Help on debugging print problem [In reply to]

Thanks Marcus, is there is a easy way to get the content length?



I tried



$length = calculate_body_len();

$r->err_headers_out->add('Content-Length' => $length);



Which gave me a corrupted content error, I also tried



my $body_len = calculate_body_len();

$r->set_content_length($body_len);

$r->rflush;



Which just did nothing.



Thx

-Chris



From: Marcus Don [mailto:mdon [at] names]
Sent: Thursday, May 30, 2013 9:12 AM
To: Chris Faust
Cc: modperl [at] perl
Subject: Re: Help on debugging print problem



At a guess, I'd say your new machine is using chunked output, so you might
need to add a size header.



Marcus





On 30 May 2013, at 12:11, "Chris Faust" <cfaust [at] doyougot> wrote:





Hi,



I have some code I use all the time I use to download a file:



if (-e '/report.pdf') {

open(PDF, '/report.pdf') or die "could not open PDF $!";

binmode PDF;

my $output = do { local $/; <PDF> };

close(PDF);

$r->content_type('application/pdf');

$r->err_headers_out->add('Content-Disposition' =>
'attachment; filename="report.pdf"');

$r->print($output);

}



I've never had a problem before using the above until trying to do it on a
new machine. On that machine every time I still get prompted to download the
file but FF/IE says its only 20 bytes (even though the pdf is 200k on the
file system) and what is downloaded is not what is on the filesystem.



I tried different files, different paths etc with the same results so I
don't think it's a location or permissions issue.



The only thing that gets logged in the attempt is:



TIGHT LOOP!!!: Apache2::RequestRec=SCALAR(0x47e2f78) can't
Apache2::RequestRec::print!



Any ideas how I could further debug that error to find the cause?



TIA!

-Chris


mdon at names

May 30, 2013, 8:59 AM

Post #4 of 5 (203 views)
Permalink
Re: Help on debugging print problem [In reply to]

I suspect you can just to this...

my $size = -s '/report.pdf';

... but to be honest I haven't used Perl in years :)

BTW It would be a lot more efficient to stream the file contents rather than read it into a variable.

Marcus





On 30 May 2013, at 16:54, "Chris Faust" <cfaust [at] doyougot> wrote:

> Thanks Marcus, is there is a easy way to get the content length?
>
> I tried
>
> $length = calculate_body_len();
> $r->err_headers_out->add('Content-Length' => $length);
>
> Which gave me a corrupted content error, I also tried
>
> my $body_len = calculate_body_len();
> $r->set_content_length($body_len);
> $r->rflush;
>
> Which just did nothing.
>
> Thx
> -Chris
>
> From: Marcus Don [mailto:mdon [at] names]
> Sent: Thursday, May 30, 2013 9:12 AM
> To: Chris Faust
> Cc: modperl [at] perl
> Subject: Re: Help on debugging print problem
>
> At a guess, I'd say your new machine is using chunked output, so you might need to add a size header.
>
> Marcus
>
>
> On 30 May 2013, at 12:11, "Chris Faust" <cfaust [at] doyougot> wrote:
>
>
> Hi,
>
> I have some code I use all the time I use to download a file:
>
> if (-e '/report.pdf') {
> open(PDF, '/report.pdf') or die "could not open PDF $!";
> binmode PDF;
> my $output = do { local $/; <PDF> };
> close(PDF);
> $r->content_type('application/pdf');
> $r->err_headers_out->add('Content-Disposition' => 'attachment; filename="report.pdf"');
> $r->print($output);
> }
>
> I've never had a problem before using the above until trying to do it on a new machine. On that machine every time I still get prompted to download the file but FF/IE says its only 20 bytes (even though the pdf is 200k on the file system) and what is downloaded is not what is on the filesystem.
>
> I tried different files, different paths etc with the same results so I don't think it's a location or permissions issue.
>
> The only thing that gets logged in the attempt is:
>
> TIGHT LOOP!!!: Apache2::RequestRec=SCALAR(0x47e2f78) can't Apache2::RequestRec::print!
>
> Any ideas how I could further debug that error to find the cause?
>
> TIA!
> -Chris
>
>
>


cfaust at doyougot

May 30, 2013, 9:04 AM

Post #5 of 5 (205 views)
Permalink
RE: Help on debugging print problem [In reply to]

Oh, I thought the header info had to be included in the length as well.



No luck there though, same Corrupted Content error. Really wish I knew what
could be causing it, no problem with the same code on 4 other machines and 3
of them are the same exact apache, mod_perl and libapreq2 versions.



Oh well, back to the drawing board.



Thanks

-Chris



From: Marcus Don [mailto:mdon [at] names]
Sent: Thursday, May 30, 2013 12:00 PM
To: Chris Faust
Cc: modperl [at] perl
Subject: Re: Help on debugging print problem



I suspect you can just to this...



my $size = -s '/report.pdf';



... but to be honest I haven't used Perl in years :)



BTW It would be a lot more efficient to stream the file contents rather than
read it into a variable.



Marcus











On 30 May 2013, at 16:54, "Chris Faust" <cfaust [at] doyougot> wrote:





Thanks Marcus, is there is a easy way to get the content length?



I tried



$length = calculate_body_len();

$r->err_headers_out->add('Content-Length' => $length);



Which gave me a corrupted content error, I also tried



my $body_len = calculate_body_len();

$r->set_content_length($body_len);

$r->rflush;



Which just did nothing.



Thx

-Chris



From: Marcus Don [mailto:mdon@ <http://names.co.uk> names.co.uk]
Sent: Thursday, May 30, 2013 9:12 AM
To: Chris Faust
Cc: <mailto:modperl [at] perl> modperl [at] perl
Subject: Re: Help on debugging print problem



At a guess, I'd say your new machine is using chunked output, so you might
need to add a size header.



Marcus





On 30 May 2013, at 12:11, "Chris Faust" < <mailto:cfaust [at] doyougot>
cfaust [at] doyougot> wrote:






Hi,



I have some code I use all the time I use to download a file:



if (-e '/report.pdf') {

open(PDF, '/report.pdf') or die "could not open PDF $!";

binmode PDF;

my $output = do { local $/; <PDF> };

close(PDF);

$r->content_type('application/pdf');

$r->err_headers_out->add('Content-Disposition' =>
'attachment; filename="report.pdf"');

$r->print($output);

}



I've never had a problem before using the above until trying to do it on a
new machine. On that machine every time I still get prompted to download the
file but FF/IE says its only 20 bytes (even though the pdf is 200k on the
file system) and what is downloaded is not what is on the filesystem.



I tried different files, different paths etc with the same results so I
don't think it's a location or permissions issue.



The only thing that gets logged in the attempt is:



TIGHT LOOP!!!: Apache2::RequestRec=SCALAR(0x47e2f78) can't
Apache2::RequestRec::print!



Any ideas how I could further debug that error to find the cause?



TIA!

-Chris

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.