[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    RE: Help on debugging print problem
From:       "Chris Faust" <cfaust () doyougot ! com>
Date:       2013-05-30 16:04:54
Message-ID: 05ee01ce5d4f$6cf94c80$46ebe580$ () com
[Download RAW message or body]

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@names.co.uk] 
Sent: Thursday, May 30, 2013 12:00 PM
To: Chris Faust
Cc: modperl@perl.apache.org
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@doyougot.com> 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@perl.apache.org> modperl@perl.apache.org
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@doyougot.com>
cfaust@doyougot.com> 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

 

 

 

 


[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" \
CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 \
(filtered medium)"><base href="x-msg://136/"><style><!-- /* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
	{mso-style-priority:99;
	mso-style-link:"Balloon Text Char";
	margin:0in;
	margin-bottom:.0001pt;
	font-size:8.0pt;
	font-family:"Tahoma","sans-serif";}
span.apple-converted-space
	{mso-style-name:apple-converted-space;}
span.EmailStyle18
	{mso-style-type:personal-reply;
	font-family:"Calibri","sans-serif";
	color:#1F497D;}
span.BalloonTextChar
	{mso-style-name:"Balloon Text Char";
	mso-style-priority:99;
	mso-style-link:"Balloon Text";
	font-family:"Tahoma","sans-serif";}
.MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div \
class=WordSection1><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Oh, I \
thought the header info had to be included in the length as \
well.<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>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.<o:p></o:p></span></p><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Oh well, \
back to the drawing board.<o:p></o:p></span></p><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks<o:p></o:p></span></p><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>-Chris<o:p></o:p></span></p><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div><div \
style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p \
class=MsoNormal><b><span \
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span \
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Marcus Don \
[mailto:mdon@names.co.uk] <br><b>Sent:</b> Thursday, May 30, 2013 12:00 \
PM<br><b>To:</b> Chris Faust<br><b>Cc:</b> modperl@perl.apache.org<br><b>Subject:</b> \
Re: Help on debugging print problem<o:p></o:p></span></p></div></div><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>I suspect you can just to \
this...<o:p></o:p></p><div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p \
class=MsoNormal>my $size = -s '/report.pdf';<o:p></o:p></p></div><div><p \
class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>... but to be \
honest I haven't used Perl in years :)<o:p></o:p></p></div><div><p \
class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p class=MsoNormal>BTW It would be a \
lot more efficient to stream the file contents rather than read it into a \
variable.<o:p></o:p></p></div><div><p \
class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p \
class=MsoNormal>Marcus<o:p></o:p></p></div><div><p \
class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p \
class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p \
class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p \
class=MsoNormal><o:p>&nbsp;</o:p></p></div><div><p \
class=MsoNormal><o:p>&nbsp;</o:p></p><div><div><p class=MsoNormal>On 30 May 2013, at \
16:54, &quot;Chris Faust&quot; &lt;<a \
href="mailto:cfaust@doyougot.com">cfaust@doyougot.com</a>&gt; \
wrote:<o:p></o:p></p></div><p class=MsoNormal><br><br><o:p></o:p></p><div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks \
Marcus, is there is a easy way to get the content \
length?</span><o:p></o:p></p></div><div><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p></div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I \
tried</span><o:p></o:p></p></div><div><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p></div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>$length = \
calculate_body_len();</span><o:p></o:p></p></div><div><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>$r-&gt;err_headers_out-&gt;add('Content-Length' \
=&gt; $length);</span><o:p></o:p></p></div><div><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p></div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Which gave \
me a corrupted content error, I also tried</span><o:p></o:p></p></div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p></div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>my \
$body_len = calculate_body_len();</span><o:p></o:p></p></div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>$r-&gt;set_content_length($body_len);</span><o:p></o:p></p></div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>$r-&gt;rflush;</span><o:p></o:p></p></div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p></div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Which just \
did nothing.</span><o:p></o:p></p></div><div><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p></div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thx</span><o:p></o:p></p></div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>-Chris</span><o:p></o:p></p></div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p></div><div><div \
style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><div><p \
class=MsoNormal><b><span \
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span \
class=apple-converted-space><span \
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>&nbsp;</span></span><span \
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>Marcus Don [mailto:mdon@<a \
href="http://names.co.uk"><span style='color:purple'>names.co.uk</span></a>]<span \
class=apple-converted-space>&nbsp;</span><br><b>Sent:</b><span \
class=apple-converted-space>&nbsp;</span>Thursday, May 30, 2013 9:12 \
AM<br><b>To:</b><span class=apple-converted-space>&nbsp;</span>Chris \
Faust<br><b>Cc:</b><span class=apple-converted-space>&nbsp;</span><a \
href="mailto:modperl@perl.apache.org"><span \
style='color:purple'>modperl@perl.apache.org</span></a><br><b>Subject:</b><span \
class=apple-converted-space>&nbsp;</span>Re: Help on debugging print \
problem</span><o:p></o:p></p></div></div></div><div><p \
class=MsoNormal>&nbsp;<o:p></o:p></p></div><div><p class=MsoNormal>At a guess, I'd \
say your new machine is using chunked output, so you might need to add a size \
header.<o:p></o:p></p></div><div><div><p \
class=MsoNormal>&nbsp;<o:p></o:p></p></div></div><div><div><p \
class=MsoNormal>Marcus<o:p></o:p></p></div></div><div><div><p \
class=MsoNormal>&nbsp;<o:p></o:p></p></div></div><div><div><p \
class=MsoNormal>&nbsp;<o:p></o:p></p></div><div><div><div><p class=MsoNormal>On 30 \
May 2013, at 12:11, &quot;Chris Faust&quot; &lt;<a \
href="mailto:cfaust@doyougot.com"><span \
style='color:purple'>cfaust@doyougot.com</span></a>&gt; \
wrote:<o:p></o:p></p></div></div><div><p \
class=MsoNormal><br><br><br><o:p></o:p></p></div><div><div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>Hi,</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>I \
have some code I use all the time I use to download a \
file:</span><o:p></o:p></p></div></div><div><div><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>if \
(-e '/report.pdf') {</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
open(PDF, '/report.pdf') or die &quot;could not open PDF \
$!&quot;;</span><o:p></o:p></p></div></div><div><div><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
binmode PDF;</span><o:p></o:p></p></div></div><div><div><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
my $output = do { local $/; &lt;PDF&gt; \
};</span><o:p></o:p></p></div></div><div><div><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
close(PDF);</span><o:p></o:p></p></div></div><div><div><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
$r-&gt;content_type('application/pdf');</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
$r-&gt;err_headers_out-&gt;add('Content-Disposition' =&gt; 'attachment; \
filename=&quot;report.pdf&quot;');</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
$r-&gt;print($output);</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>}</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>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.</span><o:p></o:p></p></div></div><div><div><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>I \
tried different files, different paths etc with the same results so I don't think \
it's a location or permissions issue.</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>The \
only thing that gets logged in the attempt \
is:</span><o:p></o:p></p></div></div><div><div><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>TIGHT LOOP!!!: \
Apache2::RequestRec=SCALAR(0x47e2f78) can't \
Apache2::RequestRec::print!</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>Any \
ideas how I could further debug that error to find the \
cause?</span><o:p></o:p></p></div></div><div><div><p class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>TIA!</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>-Chris</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;</span><o:p></o:p></p></div></div><div><div><p \
class=MsoNormal><span \
style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>&nbsp;</span><o:p></o:p></p></div></div></div></div><div><p \
class=MsoNormal>&nbsp;<o:p></o:p></p></div></div></div></div><p \
class=MsoNormal><o:p>&nbsp;</o:p></p></div></div></body></html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic