Select Page

Joomla! php, FastCGI, blank page and duplicate header ‘Status’

Joomla! php, FastCGI, blank page and duplicate header ‘Status’

joomla_cms

Since months, now I (understand also YOU) receive some blank page when browsing my Internet homepage.

This strange behavior seems to occur only when having PHP running as FastCGI

FastCGI is a protocol for interfacing interactive programs with a web server. FastCGI is a variation on the earlier Common Gateway Interface (CGI); FastCGI’s main aim is to reduce the overhead associated with interfacing the web server and CGI programs, allowing a server to handle more web page requests at once. [WikiPedia]

The Apache logs are quite explicit:

[error] [client x.x.x.x] FastCGI: comm with server “/srv/www/cgi-bin/php5” aborted: error parsing headers: duplicate header ‘Status’

The error is located in the file /libraries/joomla/environment/response.php, at the function JResponse::sendHeaders()

The way header has to be send is different when using PHP FastCgi, strange that #Joomla! 1.5.9 still do not have this in main stream code…

Old code

 function sendHeadersOld()  {   if (!headers_sent())   {    foreach ($GLOBALS['_JRESPONSE']->headers as $header)    {     if ('status' == strtolower($header['name']))     {      // 'status' headers indicate an HTTP status, and need to be handled 
     // slightly differently      header(ucfirst(strtolower($header['name'])) . ': ' . $header['value'], null, 
(int) $header['value']); } else { header($header['name'] . ': ' . $header['value']); } } } }

This is how it should look like, code is backward compatible, if PHP run as an apache module.

 function sendHeaders()  {   if (!headers_sent())   {    foreach ($GLOBALS['_JRESPONSE']->headers as $header)    {     if ('status' == strtolower($header['name']))     {      // 'status' headers indicate an HTTP status, and need to be handled 
// slightly differently
$attribute = ucfirst(strtolower($header['name'])) . ': ' . $header['value']; if (substr(php_sapi_name(), 0, 8) == 'cgi-fcgi') { $attribute = str_replace("Status:", "HTTP/1.1", $attribute); } header($attribute, null, (int) $header['value']); } else { header($header['name'] . ': ' . $header['value']); } } } }

About The Author

I worked with various Insurances companies across Switzerland on online applications handling billion premium volumes. I love to continuously spark my creativity in many different and challenging open-source projects fueled by my great passion for innovation and blockchain technology.In my technical role as a senior software engineer and Blockchain consultant, I help to define and implement innovative solutions in the scope of both blockchain and traditional products, solutions, and services. I can support the full spectrum of software development activities, starting from analyzing ideas and business cases and up to the production deployment of the solutions.I'm the Founder and CEO of Disruptr GmbH.

Categories