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

Issue Type: Bug Created: 2009-02-06T03:51:15.000+0000 Last Updated: 2011-05-10T15:38:23.000+0000 Status: Open Fix version(s): Reporter: Bas K (bas) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Controller

Related issues: Attachments:


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]; }


Posted by Joe Gornick (jgornick) on 2011-05-09T19:39:51.000+0000

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.

Posted by Aaron S. Hawley (ashawley) on 2011-05-09T19:51:37.000+0000

Never say, "never".

The current test in Zend_Controller_Request_HttpTest::testGetHeader() has

<pre class="highlight">
$_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).

<pre class="highlight">
if (isset($_SERVER['CONTENT_TYPE'])
    && !isset($_SERVER['HTTP_CONTENT_TYPE'])
) {

Posted by Joe Gornick (jgornick) on 2011-05-09T20:31:17.000+0000

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.

Posted by Bas K (bas) on 2011-05-10T15:30:19.000+0000

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

Posted by Joe Gornick (jgornick) on 2011-05-10T15:38:23.000+0000

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

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.