You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by vi...@outblaze.com on 2001/06/22 20:23:21 UTC
Re: simple question
This might help, in you httpd.conf file set this
PerlSendHeader Off
Tor.
Michael wrote:
> when using mod perl to return plain text to the client how does one
> "send" without any headers in the response stream??
>
> $r->send_fd(F)
>
> works fine for files, but how do you do it for dynamically generated
> content.
>
> Michael
>
> Michael@bizsystems.com
Re: simple question
Posted by Michael <mi...@bizsystems.com>.
> > > > This might help, in you httpd.conf file set this
> > >>
> > >> PerlSendHeader Off
> > >>
> > >> Tor.
> > >>
> > >That messes up all the standard responses. I have a work around now
> > >-- naturally it came to me moments after I posted
> > >
> > >don't know if this is "correct" so to speak, but it works fine.
> > >
> > > open(F,$file) || return 404;
> > > $r->send_fd(F);
> > > close F;
> > >
> > > pipe(R,W);
> >
> >
> > > print W "some dynamically generated text\n";
> > > close W;
> > > $r->send_fd(R);
> > > close R;
> >
> >
> > Won't this block after about 2048 bytes (on linux)?
> >
>
> Yep, you are right... bummer! there must be a better way. Certainly
> don't want to fork in Apache::mod_perl. Perhaps embedding the pipe
> process in a loop and breaking the strings into blocks < 2048 would
> be more efficient. If the darn headers could just be turned off it
> would be a piece of cake. Like
>
> $r->send_cgi_header()
> Take action on certain headers including Status:,
> Location: and Content-type: just as mod_cgi does, then
> calls $r->send_http_header(). Example of use:
>
> but without the call to $r-send_http_header()
>
what is the system overhead of something like this vs a fork
sub pipe_write {
my ($tp) = @_;
my $len = length($$tp);
my $off = 0;
while (1) {
my $ln = ($len-$off > 1024) ? 1024 : $len-$off;
pipe(R,W);
print W substr($$tp,$off,$ln);
close W;
$r->send_fd(R);
close R;
$off += $ln;
last if $off >= $len;
}
}
Michael@bizsystems.com
Re: simple question
Posted by Michael <mi...@bizsystems.com>.
> > > This might help, in you httpd.conf file set this
> >>
> >> PerlSendHeader Off
> >>
> >> Tor.
> >>
> >That messes up all the standard responses. I have a work around now
> >-- naturally it came to me moments after I posted
> >
> >don't know if this is "correct" so to speak, but it works fine.
> >
> > open(F,$file) || return 404;
> > $r->send_fd(F);
> > close F;
> >
> > pipe(R,W);
>
>
> > print W "some dynamically generated text\n";
> > close W;
> > $r->send_fd(R);
> > close R;
>
>
> Won't this block after about 2048 bytes (on linux)?
>
Yep, you are right... bummer! there must be a better way. Certainly
don't want to fork in Apache::mod_perl. Perhaps embedding the pipe
process in a loop and breaking the strings into blocks < 2048 would
be more efficient. If the darn headers could just be turned off it
would be a piece of cake. Like
$r->send_cgi_header()
Take action on certain headers including Status:,
Location: and Content-type: just as mod_cgi does, then
calls $r->send_http_header(). Example of use:
but without the call to $r-send_http_header()
Michael
Michael@bizsystems.com
Re: simple question
Posted by Robert Landrum <rl...@capitoladvantage.com>.
> > This might help, in you httpd.conf file set this
>>
>> PerlSendHeader Off
>>
>> Tor.
>>
>That messes up all the standard responses. I have a work around now
>-- naturally it came to me moments after I posted
>
>don't know if this is "correct" so to speak, but it works fine.
>
> open(F,$file) || return 404;
> $r->send_fd(F);
> close F;
>
> pipe(R,W);
> print W "some dynamically generated text\n";
> close W;
> $r->send_fd(R);
> close R;
Won't this block after about 2048 bytes (on linux)?
I thought pipe was only appropriate when forking was in use...
pipe(R,W);
if(fork) {
print W "2048 or more bytes of text\n";
close W;
} else {
$r->send_fd(R);
close R;
}
The reason for this was so that the write wouldn't block. In your
example, there is nothing reading the data from the pipe, so once the
buffer is full, writes will block until the data is read. I could be
wrong....
Rob
--
Rome didn't become great by having meetings; they did it by killing
all those who opposed them.
Re: simple question
Posted by Michael <mi...@bizsystems.com>.
> This might help, in you httpd.conf file set this
>
> PerlSendHeader Off
>
> Tor.
>
That messes up all the standard responses. I have a work around now
-- naturally it came to me moments after I posted
don't know if this is "correct" so to speak, but it works fine.
open(F,$file) || return 404;
$r->send_fd(F);
close F;
pipe(R,W);
print W "some dynamically generated text\n";
close W;
$r->send_fd(R);
close R;
> Michael wrote:
>
> > when using mod perl to return plain text to the client how does one
> > "send" without any headers in the response stream??
> >
> > $r->send_fd(F)
> >
> > works fine for files, but how do you do it for dynamically generated
> > content.
> >
> > Michael
> >
> > Michael@bizsystems.com
>