We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Service Request getHeader / getHeaders

Apparently all results from:


are in upper case.

From HTTP1.1 specs, HTTP headers are case insensitive. But it looks like Phalcon always converts them to uppercase. Is this correct? Will Phalcon always convert headers to uppercase?

There is no problem whatsoever with this behaviour, I just want to make sure I can always rely (PHP wise) on the uppercase version when using $app->request->getHeader("MY-HEADER") even though My-Header was my original header.


Ohhh, and converts dashes (and maybe others) to underscores !??

edited Jul '15

In latest Phalcon (2.x), it's quite the opposite.

$client = $app->request->getHeader('API_ID'); //This is correct, since the original header is sent in that form

But, if you check the output from this method:

$headers = $app->request->getHeaders(); //print_r($headers); echo $headers['Api-Id']; //now the original field looks like that! Underscore changed to dash, and Sentence Case! That's just not right.

Nothing should change original HTTP headers sent from the client or API. It is extremely difficult to check what client sent! The most logic way would be with getHeaders() method, but that's just not working since it will give you false result!?