Re: Need some help hijacking the page output pipe

[prev] [thread] [next] [Date index for 2004/11/11]

From: Mark S Lowe
Subject: Re: Need some help hijacking the page output pipe
Date: 22:36 on 11 Nov 2004
--B_3183028587_8628640
Content-type: text/plain;
	charset="ISO-8859-1"
Content-transfer-encoding: quoted-printable

Thank you. This worked perfectly. I was also able to add test code from
chapter 4 of Writing Apache Modules with Perl and C, and add file tests.

I knew my first post to this mailing list had to be stupid. ;-)


On 11/11/04 2:21 PM, "Tom Schindl" <tomAtLinux@xxx.xx> wrote:

> Mark S Lowe wrote:
>=20
>> > I have a need to create my own suffix and hijack the output for page
>> > rendering code, and then re-output the page with my own OK. I have the
>> > O=B9Reilly book =B3Practical mod_perl=B2 and there is a great example of
>> > this on page 114 in Chapter 4. However, the example is incomplete. The
>> > example suggests that we can intercept the request for a page, remove
>> > all the HTML tags, and re-output the page. This isn=B9t exactly what I
>> > want to do, but it will server as a great architecture for my needs.
>> >
>> > I=B9ve got my <Files> directive working perfectly in httpd.conf, but now
>> > I need some help intercepting the page request event, re-rendering the
>> > page, and then outputting it. I imagine this is like a three line
>> > explanation, but I can=B9t seem to find it anywhere. I imagine it
>> > something like this:
>> >
>> > PerlModule MyPlatform::Converter
>> > <Files ~ "\.(pla)$">
>> > SetHandler perl-script
>> > PerlHandler MyPlatform::HTML2TextConverter MyPlatform::
>> > HTMLContentGenerator
>> > </Files>
>> >
>> > I just don=B9t know how to grab the HTML page text once it gets to my
>> > module. STDIN doesn=B9t have it. So where is it?
>> >
>> > Suggestions?
>> >
>> > Thanks!
>> >
>> > Mark=20
>=20
> Well you have to read the file yourself:
>=20
> package MyPlatform::HTML2TextConverter MyPlatform:: HTMLContentGenerator;
>=20
> sub handler {
> # .....
> my $content;
>=20
>   local $/ =3D undef;
>   open( READFILE, |$r->filename| );
>   $content =3D <READFILE>;
>   close( READFILE );
>   # ...
>=20
> }



--B_3183028587_8628640
Content-type: text/html;
	charset="ISO-8859-1"
Content-transfer-encoding: quoted-printable

<HTML>
<HEAD>
<TITLE>Re: Need some help hijacking the page output pipe</TITLE>
</HEAD>
<BODY>
<FONT FACE=3D"Verdana, Helvetica, Arial"><SPAN STYLE=3D'font-size:12.0px'>Thank=
 you. This worked perfectly. I was also able to add test code from chapter 4=
 of Writing Apache Modules with Perl and C, and add file tests. <BR>
<BR>
I <I>knew</I> my first post to this mailing list had to be stupid. ;-)<BR>
<BR>
<BR>
On 11/11/04 2:21 PM, &quot;Tom Schindl&quot; &lt;tomAtLinux@xxx.xx&gt; wrot=
e:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT SIZE=3D"1"><FONT FACE=3D"Monaco, Courier New"><=
SPAN STYLE=3D'font-size:9.0px'>Mark S Lowe wrote:<BR>
<BR>
&gt; I have a need to create my own suffix and hijack the output for page <=
BR>
&gt; rendering code, and then re-output the page with my own OK. I have the=
 <BR>
&gt; O&#8217;Reilly book &#8220;Practical mod_perl&#8221; and there is a gr=
eat example of <BR>
&gt; this on page 114 in Chapter 4. However, the example is incomplete. The=
 <BR>
&gt; example suggests that we can intercept the request for a page, remove =
<BR>
&gt; all the HTML tags, and re-output the page. This isn&#8217;t exactly wh=
at I <BR>
&gt; want to do, but it will server as a great architecture for my needs.<B=
R>
&gt;<BR>
&gt; I&#8217;ve got my &lt;Files&gt; directive working perfectly in httpd.c=
onf, but now <BR>
&gt; I need some help intercepting the page request event, re-rendering the=
 <BR>
&gt; page, and then outputting it. I imagine this is like a three line <BR>
&gt; explanation, but I can&#8217;t seem to find it anywhere. I imagine it =
<BR>
&gt; something like this:<BR>
&gt;<BR>
&gt; PerlModule MyPlatform::Converter<BR>
&gt; &lt;Files ~ &quot;\.(pla)$&quot;&gt;<BR>
&gt; SetHandler perl-script<BR>
&gt; PerlHandler MyPlatform::HTML2TextConverter MyPlatform:: <BR>
&gt; HTMLContentGenerator<BR>
&gt; &lt;/Files&gt;<BR>
&gt;<BR>
&gt; I just don&#8217;t know how to grab the HTML page text once it gets to=
 my <BR>
&gt; module. STDIN doesn&#8217;t have it. So where is it?<BR>
&gt;<BR>
&gt; Suggestions?<BR>
&gt;<BR>
&gt; Thanks!<BR>
&gt;<BR>
&gt; Mark <BR>
<BR>
Well you have to read the file yourself:<BR>
<BR>
package MyPlatform::HTML2TextConverter MyPlatform:: HTMLContentGenerator;<B=
R>
<BR>
sub handler {<BR>
# .....<BR>
my $content;<BR>
<BR>
&nbsp;&nbsp;local $/ =3D undef;<BR>
&nbsp;&nbsp;open( READFILE, |$r-&gt;filename| );<BR>
&nbsp;&nbsp;$content =3D &lt;READFILE&gt;;<BR>
&nbsp;&nbsp;close( READFILE );<BR>
&nbsp;&nbsp;# ...<BR>
<BR>
}<BR>
</SPAN></FONT></FONT></BLOCKQUOTE><FONT SIZE=3D"1"><FONT FACE=3D"Monaco, Courie=
r New"><SPAN STYLE=3D'font-size:9.0px'><BR>
</SPAN></FONT></FONT>
</BODY>
</HTML>


--B_3183028587_8628640--


Need some help hijacking the page output pipe
Mark S Lowe 21:30 on 11 Nov 2004

Re: Need some help hijacking the page output pipe
Mark S Lowe 22:36 on 11 Nov 2004

Generated at 11:26 on 21 Dec 2004 by mariachi v0.52