HTTP 304 status not sent correctly on PHP 5.2, breaking conditional GET on feeds
|Reported by:||kelson||Owned by:||anonymous|
Description (last modified by foolswisdom)
After upgrading to WordPress 2.0.6, I noticed that my feeds were no longer working. In several browsers and readers, including Firefox, IE7, Konqueror and Akregator, only blank files were being sent. Server logs indicated a 200 response with a few hundred bytes, but browsers showed only an empty file. Oddly, Opera, Dillo, and command-line GET displayed the files fine.
Looking at the actual HTTP response headers, it turned out that on conditional GETs that were supposed to issue 304 Not Modified, the server was actually issuing the following:
HTTP/1.1 200 OK
Status: 304 Not Modified
This resulted in a 200 OK status and empty response body.
I looked through and found that the status was being set in wp-includes/functions.php, in the status_header function. I changed the following line:
@header("Status: $header $text");
@header("Status: $header $text", TRUE, $header);
After making that change, status headers were sent correctly. Once I cleared the browser cache, feeds started loading again.
Going by the recommended method in the PHP manual, I also tried commenting out the if statement regarding the PHP API, so that only the following statement would run:
@header("HTTP/1.1 $header $text");
This also worked correctly.
This is with PHP 5.2.0 on Apache 1.3.37 (yes, I do intend to upgrade it eventually) using the mod_php interface.