Commit 6c73823b authored by Steven Wittens's avatar Steven Wittens
Browse files

Fixing a rather nasty bug with page cache:

The headers stored for cached pages ended in a newline, which caused header("") to get called when serving the page.
On some PHP versions (happens on 4.3.3 at least, but not in 5.0), PHP adds a blank header to the HTTP request (i.e. just \r\n) which ends HTTP headers prematurely and adds a newline at the beginning of the page.

This was not an issue before because we output HTML. Now that we have GZip compression, this bug caused corruption of the output. :P
parent cd632f62
......@@ -162,13 +162,16 @@ function drupal_get_normal_path($path) {
* @{
function drupal_set_header($header = NULL) {
static $stored_headers = '';
// We use an array to guarantee there are no leading or trailing delimiters.
// This can cause header("") to get called when serving the page later, which
// ends HTTP headers prematurely on some PHP versions.
static $stored_headers = array();
if (!is_null($header)) {
if (strlen($header)) {
$stored_headers .= $header ."\n";
$stored_headers[] = $header;
return $stored_headers;
return implode("\n", $stored_headers);
function drupal_get_headers() {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment