Patch to make 304 responses more 'standard' on Apache

From: Date: Sat, 02 Dec 2000 00:10:28 +0000
Subject: Patch to make 304 responses more 'standard' on Apache
Groups: php.dev 
Request: Send a blank email to php-dev+get-39818@lists.php.net to get a copy of this message
Hello everyone, As I've mentioned in previous posts, when one manually sends out a 304 (Not Modified) response using PHP code like: header("HTTP/1.0 304"); it is sending out a Content-Type header. I've found that this happens because mod_php4.c is calling send_http_header() regardless of the response code, and that function unconditionally tacks on a Content-Type header. From what I understand, it shouldn't be doing this. When returning 304 for static HTML pages or CGI scripts, Apache strips out Content-Type and other headers. (According to a comment in http_protocol.c: "We need to special-case the handling of 204 and 304 responses, since they have specific HTTP requirements and do not include a message body.") The attached patch (applicable to the latest CVS version) makes two changes. 1) mod_php4.c now uses send_error_response() instead of send_http_header() when returning 304. This makes PHP work just like Apache does with static HTML & CGI scripts; all inapplicable headers get stripped out. 2) This change isn't Apache-specific: SAPI.c now sets headers_only to 1 when it encounters a 304 header. The reason for doing this is so no body is ever sent out, either accidentally or due to an error condition (e.g. a PHP warning). I don't see any drawback to doing this, since HTTP mandates that there be no body when 304 is returned. Comments? Jordan Russell

Attachment: [application/octet-stream] php4-304fix.patch
« previous php.dev (#39818) next »