if (eval{tell STDOUT}) {
print STDOUT $mess;
}
else {
print STDOUT "Content-type: text/html\n\n";
print STDOUT $mess;
}
but it definitely doesn't work on OSX with Apache. tell STDOUT always
seems to return "-1", which then means that CGI::Carp never outputs a
header. Ooops.
Perhaps that can be changed to
if (eval {tell STDOUT} > 0) { ... }
but since I don't completely understand the problem, maybe it can be
explained.
Is there any platform for which this works? And then I wonder
what's different about OSX (again :).
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Looks like something that should be sent to per...@perl.org for safe
keeping. That would be most useful.
Casey West
--
Shooting yourself in the foot with Smalltalk
You spend so much time playing with the graphics and windowing system
that your boss shoots you in the foot, takes away your workstation and
makes you develop in COBOL on a character terminal.
What's Apache? I suppose you are talking about mod_perl 1.0, and not mod_cgi.
Indeed it doesn't provide the tell function (hence you get -1: not
implemented), because it makes no sense (all data is sent to Apache which
sends it out and won't be able to tell(), or seek() on the tied STDOUT)
So if that's the case, all is needed is to make CGI::Carp mod_perl aware, e.g.:
# provided that we have $MOD_PERL and $r ($self->r) like CGI.pm does
sub http_header_is_sent {
if ($MOD_PERL) {
return $r->sent_header;
} else {
return eval{tell STDOUT};
}
}
...
if (http_header_is_sent()) {
print STDOUT $mess;
}
else { .... }
I've moved the logic into a dedicated function, so that other special cases
can be added there.
In the future you may want to post mod_perl related issue to the mod_perl list.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:st...@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
Stas> What's Apache? I suppose you are talking about mod_perl 1.0, and not
Stas> mod_cgi.
No, mod_cgi.
Stas> I've moved the logic into a dedicated function, so that other special
Stas> cases can be added there.
Stas> In the future you may want to post mod_perl related issue to the mod_perl list.
This is not a mod_perl issue.
ftell(2) is supposed to return -1 on error, so your proposed change looks
correct. (output a header only if nothing has been written yet to standard
output.)
> Perhaps that can be changed to
>
> if (eval {tell STDOUT} > 0) { ... }
>
> but since I don't completely understand the problem, maybe it can be
> explained.
>
> Is there any platform for which this works? And then I wonder
> what's different about OSX (again :).
What is STDOUT according to stat() ? a filehandle, a tty, a pipe ?
Is it tied in some way ? Can you reproduce this problem stand-alone ?
if it's a pipe, a return value of -1 is probably expected.
Lincoln
On Wednesday 03 December 2003 03:49 pm, Randal L. Schwartz wrote:
> I'm not sure what the author of this code was thinking:
>
> if (eval{tell STDOUT}) {
> print STDOUT $mess;
> }
> else {
> print STDOUT "Content-type: text/html\n\n";
> print STDOUT $mess;
> }
>
> but it definitely doesn't work on OSX with Apache. tell STDOUT always
> seems to return "-1", which then means that CGI::Carp never outputs a
> header. Ooops.
>
> Perhaps that can be changed to
>
> if (eval {tell STDOUT} > 0) { ... }
>
> but since I don't completely understand the problem, maybe it can be
> explained.
>
> Is there any platform for which this works? And then I wonder
> what's different about OSX (again :).
--
========================================================================
Lincoln D. Stein Cold Spring Harbor Laboratory
lst...@cshl.org Cold Spring Harbor, NY
========================================================================
Lincoln