diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2004-07-29 01:41:33 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2004-07-29 01:41:33 +0000 |
commit | 6c73823b10bed9baebfa681967bc320f69b7d813 (patch) | |
tree | 487e8dcae50bb26fe9878a2fb901e80bf8160dd0 | |
parent | cd632f62510bb78a619cb40a316478ca47ca5249 (diff) | |
download | brdo-6c73823b10bed9baebfa681967bc320f69b7d813.tar.gz brdo-6c73823b10bed9baebfa681967bc320f69b7d813.tar.bz2 |
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
*phew*
-rw-r--r-- | includes/common.inc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/includes/common.inc b/includes/common.inc index 4ea42b449..9b8d6fcc6 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -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)) { header($header); - $stored_headers .= $header ."\n"; + $stored_headers[] = $header; } - return $stored_headers; + return implode("\n", $stored_headers); } function drupal_get_headers() { |