Re: mod_layout change HTTP header

Brian Aker <[email protected]> Sat, 24 Feb 2007 09:44:26 -0800
Newsgroups gmane.comp.apache.mod-layout
Message-ID <[email protected]>
Hi!

On Feb 24, 2007, at 6:54 AM, - = k o l i s k o = - wrote:

> I want a simple thing to do. I want generate my own HTTP headers by  
> PHP and
> than add a footer before </body> tag by mod_layout without change HTTP
> headers generated by PHP.

This is quite doable in Apache 2.0 and its version of mod_layout. For  
1.3 you would need to go into the loop which
copies  headers and add additional headers to be copied.

> Reason is easy. I have lot of websites on my server which has .png  
> images
> stored in mysql database. These images are displayed by PHP. Somethink
> like /showimage.php?id=123. It means that showimage.php get image  
> from mysql
> and display it by generate HTTP Content-Type: image/png header  
> using standard
> header() function in PHP.

This is different though, you would not be generating a footer on the  
image in this case.

I believe this works right in 2.0, but if it did not you would need  
to just extend in layout_filter()
the method by which it skips requests.

>  I think that want easy thing and hope that it is possible to do by
> mod_layout. Or if it is not possible to do by mod_layout, what is  
> better for
> my need?

If you need 1.3 then its filter would need to be extended to drop  
requests if it saw a content type
it should not handle. There layout_handler() would need to be  
modified to do pass through (though it
would still not preserve headers since the headers were removed via  
layout_fixup() when the file pointer was hijacked).

Cheers,
	-Brian

>
>
> On Friday 23 of February 2007 23:19:51 Brian Aker wrote:
>> Hi!
>>
>> mod_layout for Apache 1.3 grabs the document after the generator is
>> done with it. To do this it turns off the headers for the original
>> document and then generates its own headers. What are you wanting  
>> to do?
>>
>>  From looking at your description it looks like a second check for
>> content-type should be made to avoid scrambling output like yours
>> (though you can do this through ignore uri bits as well).
>>
>> Cheers,
>> 	-Brian
>>
>> On Feb 23, 2007, at 11:26 AM, - = k o l i s k o = - wrote:
>>> Hi all,
>>>
>>> i have installed mod_layout on Debian Sarge server (versions bellow)
>>>
>>>
>>> cut /etc/apache/httpd.conf
>>>
>>> LayoutMerge ON
>>> LayoutFooter "foot"     # only for test
>>>
>>> When i have easy test.php page like this all work well:
>>>
>>> <html>
>>> <body>
>>> <?
>>> echo "test body";
>>> ?>
>>> </body>
>>> </html>
>>>
>>>
>>> this is output from 'dog' tool:
>>>
>>> HTTP/1.1 200 OK
>>> Date: Fri, 23 Feb 2007 18:58:51 GMT
>>> Server: Apache/1.3.33 (Debian GNU/Linux) PHP/4.3.10-18 mod_layout/
>>> 3.2.1
>>> X-Powered-By: ModLayout/3.2.1
>>> Connection: close
>>> Content-Type: text/html
>>>
>>>
>>> <html>
>>> <body>
>>> test bodyfoot</body>
>>> </html>
>>>
>>>
>>> It is all ok
>>>
>>> BUT
>>>
>>> When when i use a simple php code with function header(), which
>>> adds/change
>>> HTTP headers, it looks that mod_layout always replays the headers
>>> by itself.
>>> I use changing HTTP headers to "image/png" value becouse i generate
>>> dynamic .png images by php scripts.
>>>
>>> This is second simple test.php page:
>>>
>>> <?
>>> Header("Content-Type: image/png");
>>> Header("NewHeder: value");
>>> ?>
>>>
>>> output from dog:
>>>
>>> HTTP/1.1 200 OK
>>> Date: Fri, 23 Feb 2007 19:08:43 GMT
>>> Server: Apache/1.3.33 (Debian GNU/Linux) PHP/4.3.10-18 mod_layout/
>>> 3.2.1
>>> X-Powered-By: ModLayout/3.2.1
>>> Connection: close
>>> Content-Type: text/html
>>>
>>>
>>> You can see no HTTP headers generated by test.php script
>>>
>>> when i turn off LayoutFooter and LayoutMerge in httpd.conf and
>>> restart apache,
>>> dog show me:
>>>
>>> HTTP/1.1 200 OK
>>> Date: Fri, 23 Feb 2007 19:14:47 GMT
>>> Server: Apache/1.3.33 (Debian GNU/Linux) PHP/4.3.10-18 mod_layout/
>>> 3.2.1
>>> X-Powered-By: PHP/4.3.10-18
>>> NewHeder: value
>>> Connection: close
>>> Content-Type: image/png
>>>
>>>
>>> Any idea why mod_layout change HTTP header? I use mod_layout
>>> becouse only want
>>> add a text or simple html code before "</body>" tag without change
>>> HTTP
>>> headers or without change anything else....
>>>
>>> Thank you for help!!!
>>>
>>> kolisko
>>>
>>> versions on my Debian Sarge server - dpkg -l :
>>>
>>>
>>> ii  apache         1.3.33-6sarge3 versatile, high-performance HTTP
>>> server
>>> ii  apache-common  1.3.33-6sarge3 support files for all Apache
>>> webservers
>>> ii  apache-dev     1.3.33-6sarge3 development kit for the Apache
>>> webserver
>>> ii  apache-ssl     1.3.33-6sarge3 versatile, high-performance HTTP
>>> server with
>>> ii  apache-utils   1.3.33-6sarge3 utility programs for webservers
>>> (transitiona
>>> ii  apache2        2.0.54-5sarge1 next generation, scalable,
>>> extendable web se
>>> ii  apache2-common 2.0.54-5sarge1 next generation, scalable,
>>> extendable web se
>>> ii  apache2-mpm-pr 2.0.54-5sarge1 traditional model for Apache2
>>> ii  apache2-utils  2.0.54-5sarge1 utility programs for webservers
>>> ii  libapache-mod-layout 3.2.1-2        Apache web page content
>>> wrapper
>>> ii  libapache2-mod 4.0.1a-2.2     Apache2 web page content wrapper
>>> ii  libapache2-mod 4.3.10-18      server-side, HTML-embedded
>>> scripting languag
>>> _______________________________________________
>>> Mod_layout mailing list
>>> [email protected]
>>> http://lists.tangent.org/mailman/listinfo/mod_layout
>>
>> --
>> _______________________________________________________
>> Brian "Krow" Aker, brian at tangent.org
>> Seattle, Washington
>> http://krow.net/
>> http://tangent.org/
>> _______________________________________________________
>> You can't grep a dead tree.
>>
>>
>> _______________________________________________
>> Mod_layout mailing list
>> [email protected]
>> http://lists.tangent.org/mailman/listinfo/mod_layout
>
>
> _______________________________________________
> Mod_layout mailing list
> [email protected]
> http://lists.tangent.org/mailman/listinfo/mod_layout

--
_______________________________________________________
Brian "Krow" Aker, brian at tangent.org
Seattle, Washington
http://krow.net/
http://tangent.org/
_______________________________________________________
You can't grep a dead tree.