Ray,

Did some tests with you code thought it may help.

I am on Apache 2.5.3 with mod_perl 2.1 and perl 5.8.5 and I have the same exact result with your code examples.

Other scripts I have will not work without $|=1; before printing. It's frustrating. I am also having to re-arrange my print functions in my scripts.

By the way, a lot of my scripts use CGI::Compress::Gzip, seems as though it is saving me from a lot of trouble that I didn't know about until running some scripts without it.

--------------------------------------------------------------------------------
$|=1;
use DBI;
use Date::Calc qw(:all);
use CGI::Carp qw(fatalsToBrowser);
use CGI;
use Time::Local;
use CGI::Compress::Gzip;

my $now=time;
 my $then=$now+3600;
 my @vals=split(" ",scalar gmtime($then));
my $expiration="expires= $vals[0], $vals[2]-$vals[1]-$vals[4] $vals[3] GMT";

my $path="/";
my $cookie="Set-Cookie: TEST=TestCookie; $expiration;  path=$path;
domain=127.0.0.1;n";

#$|=1;
print $cookie;

my $q = CGI::Compress::Gzip->new;
print $q->header;
# print "Cache-Control: no-cache\nContent-type: text/html\n\n";
#$|=1;

print "<HTML>Started "."time".time()."<br></HTML>\n";
--------------------------------------------------------------------------------

That code runs fine on my system.

Also, using your Failing Script. If I don't set the buffer to flush at all, it works.

#$|=1;
print $cookie;

Tony

Ray Hunter wrote:

OK I've managed to get this down to the bare bones and be 100% reproduceable....
two scripts are enclosed. The only difference is the buffer handling. Maybe you
could test this on your server to see if you get the same result.


1. Working script

use DBI;
use Date::Calc qw(:all);
use CGI::Carp qw(fatalsToBrowser);
use CGI;
use Time::Local;

my $now=time;
 my $then=$now+3600;
 my @vals=split(" ",scalar gmtime($then));
 my $expiration="expires= $vals[0], $vals[2]-$vals[1]-$vals[4] $vals[3] GMT";

my $path="/";
my $cookie="Set-Cookie: TEST=TestCookie; $expiration;  path=$path;
domain=127.0.0.1;n";

$|=0;
print $cookie;

print "Cache-Control: no-cachenContent-type: text/html;charset=ISO-8859-1nn";
$|=1;

print "<HTML>Started "."time".time()."<br></HTML>n";


2. Failing Script
use DBI;
use Date::Calc qw(:all);
use CGI::Carp qw(fatalsToBrowser);
use CGI;
use Time::Local;

my $now=time;
 my $then=$now+3600;
 my @vals=split(" ",scalar gmtime($then));
 my $expiration="expires= $vals[0], $vals[2]-$vals[1]-$vals[4] $vals[3] GMT";

my $path="/";
my $cookie="Set-Cookie: TEST=TestCookie; $expiration;  path=$path;
domain=127.0.0.1;n";

$|=1;
print $cookie;

print "Cache-Control: no-cachenContent-type: text/html;charset=ISO-8859-1nn";
#$|=1;

print "<HTML>Started "."time".time()."<br></HTML>n";





----- Forwarded message from Ray Hunter <[EMAIL PROTECTED]> -----
   Date: Thu, 11 Aug 2005 18:18:17 +0200
   From: Ray Hunter <[EMAIL PROTECTED]>
Reply-To: Ray Hunter <[EMAIL PROTECTED]>
Subject: 103 Buffer FLush & modperl
     To: [EMAIL PROTECTED]

on ASPN you wrote:
I have been getting some strange error on my system lately, so I took
the time to completely upgrade my server last night to see of I could
fix the problem with new updates. First thing this morning the errors
re-surfaced.


I had similar issues recently.

I installed some old scripts onto a new machine running Apache 2.0.54, modperl,
and PERL 5.8.7

These scripts had been running OK for a long time.

Then all of a sudden I kept getting complaints about the script not sending a
complete header....

Looks like the problem was related to buffer flushing.

If we had

$|=1;
print $cookie;
print "Cache-Control: no-cachenContent-type: text/html;charset=ISO-8859-1nn";
print $HTML;

it fails with a 500 internal server error:Premature end of script headers: x.cgi


but

print $cookie;
print "Cache-Control: no-cachenContent-type: text/html;charset=ISO-8859-1nn";
$|=1;
print $HTML;

works just fine.

Seems there is something new/dodgy in the modperl buffer flushing mechanism that
is saying: hey our buffer is being flushed, but we have not sent the header yet
= script error.


Ray Hunter : Network Consultant
[EMAIL PROTECTED]
Globis Consulting BV, Dillenburgstraat 9a, 5652AM Eindhoven NL,
Registered at the KvK, Eindhoven, under number BV 17098279
tel: +31 620 363864

----- End forwarded message -----


Ray Hunter : Network Consultant
[EMAIL PROTECTED]
Globis Consulting BV, Dillenburgstraat 9a, 5652AM Eindhoven NL,
Registered at the KvK, Eindhoven, under number BV 17098279
tel: +31 620 363864


Reply via email to