ZF-5705: Zend_Controller_Request_Http::getHeader returns false for an "Content Type" lookup in some installations.


The method for retrieving headers is not complete so when the method apache_request_headers() is not available false will be returned on some systems

This happens when the $SERVER does not contains 'HTTP_CONTENT_TYPE' but 'CONTENT_TYPE', since the system looks for HTTP + requestvar.

(line 950)

$temp = 'HTTP_' . strtoupper(str_replace('-', '_', $header)); if (!empty($_SERVER[$temp])) { return $_SERVER[$temp]; }

After the above the following could be added $temp = strtoupper(str_replace('-', '_', $header)); if (!empty($_SERVER[$temp])) { return $_SERVER[$temp]; }


The issue here is that CONTENT_TYPE and CONTENT_LENGTH are not prefixed with HTTP_. The reason is because CONTENT_TYPE and CONTENT_LENGTH are not protocol specific meta-variables (

So, unless you have the apache_request_headers method available, the type and length of the request are never obtained for the request.

Never say, "never".

The current test in Zend_Controller_Request_HttpTest::testGetHeader() has

$_SERVER['HTTP_CONTENT_TYPE']    = 'text/json';

So it would seem some PHP environments do put HTTP_CONTENT_TYPE in $_SERVER.

I'm not sure what the appropriate patch to Zend_Controller_Request_Http is, but I know I add this to dispatch script (public/index.php).

if (isset($_SERVER['CONTENT_TYPE'])
    && !isset($_SERVER['HTTP_CONTENT_TYPE'])
) {

I'd be interested to find out what environments return HTTP_CONTENT_TYPE.

In regards to a patch for HTTP requests, I would say we try to load the requested meta variable without the HTTP prefix, then if not found, add the HTTP prefix and try that.

i believe when i submitted this issue i was developing on an CentOS 5 system with php5.2.something

I'm experiencing it on Windows XP with Apache 2.2/PHP5.3.x.