On Thu, 7 Sep 2000, Subhash Sankuratripati wrote:
> Hello,
> I would like to find out how can I write to the HTTP Client from an
> XS module written in C being called from a Perl module running under apache.
>
> Even trying syswrite 1, "test" does not work from mod_perl. So
> internally mod_perl is duping stdout to some other file handle and
> eventually writing it to the accepted socket desc. from the client.
mod_perl does not touch stdout. under cgi, stdout is connected to a
pipe which is fed back to the client by mod_cgi, not the case with
mod_perl.
have a look at Apache::Peek on cpan, which redirects stderr to the client
with a few defines:
#ifdef MOD_PERL
#include "modules/perl/mod_perl.h"
#undef PerlIO
#undef PerlIO_printf
#undef PerlIO_vprintf
#undef PerlIO_stderr
#undef PerlIO_putc
#undef PerlIO_puts
#define PerlIO request_rec
#define PerlIO_printf rprintf
#define PerlIO_vprintf(r,fmt,vlist) \
vbprintf(r->connection->client, fmt, vlist)
#define PerlIO_stderr() perl_request_rec(NULL)
#define PerlIO_putc(r,c) rputc(c,r)
#define PerlIO_puts(r,s) rputs(s,r)