Bug 33499 - AddOutputFilterByType won't work reliably with PHP
Summary: AddOutputFilterByType won't work reliably with PHP
Status: RESOLVED LATER
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: Core (show other bugs)
Version: 2.0.53
Hardware: All All
: P2 minor (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
: 45799 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-02-10 19:59 UTC by Rici Lake
Modified: 2011-03-26 11:12 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rici Lake 2005-02-10 19:59:30 UTC
PHP calls ap_set_content_type for generated content with an explicit content-type header. It calls it 
once at the beginning of the handler in order to set the content-type to the default (usually text/html) 
and then calls it again if the php script sends a Content-Type header.

ap_set_content_type attaches filters configured by AddOutputFilterByType when it is called. 
Consequently, PHP generated pages will have both the text/html output filters and the output filters for 
the actual content type added.

As Nick Kew says in response to bug 31226, "AddOutputFilterbyType is known to be broken." Fixing 
this problem does not appear to me to be easy; I would recommend documenting ap_set_content_type 
in include/http_protocol.h to add a warning that ap_set_content_type should not be called twice for the 
same request.

I'm submitting this bug by way of documentation.
Comment 1 Paul Querna 2005-06-03 01:12:43 UTC
I think PHP should change their behavoir, and only call ap_set_content_type when
they are ready to send the headers.
Comment 2 Nick Kew 2005-06-19 16:19:29 UTC
I can't entirely agree with either of you.  Different modules may need to use  
ap_set_content_type without reference to each other.   AddOutputFilterbyType 
adds a malevolent interaction that breaks modularity. 
 
Time to propose removing AddOutputFilterbyType altogether for 2.1? 
Comment 3 Nick Kew 2008-09-13 06:06:54 UTC
*** Bug 45799 has been marked as a duplicate of this bug. ***
Comment 4 Nick Kew 2011-03-26 11:12:52 UTC
This is fixed in trunk by moving the directive to mod_filter.  Won't backport - use mod_filter directly instead.