[PHP] php.Web.getClientHeaders() alternative

Hej !

php.Web.getClientHeaders() is deprecated, what is the best alternative for that pease ?

tink_http :wink:

Hej Kevin !

Thanks for your answer, but I try to escape as possible external libs…
If it can be done in pure Haxe/PHP quite simply it will be good.

I really love Juraj’s tink libs but it’s all dependant of all, the little thing you want to use come with billion of libs/classes … :confused:

Sorry, I’ve forgotten mention you, I’ve seen you also work a lot on tink libs. Thanks !


1 Like

Thanks Aleksandr !
It could be great to have a better message something like is deprecated. Use Std.isOfType instead. that suggest the exact function to use instead of just a class (Global and SuperGlobal) :stuck_out_tongue:
BTW, can I ask you maybe what to use instead of php.setReturnCode()? Is this a good thing or is there a shortcut ? php.Global.header( "HTTP/1.1 401 Unauthorized", 401 ); ?

That’s exactly what php.Web.setReturnCode(401) does under the hood.

php.Syntax.code("http_response_code({0})", 401);

Thanks Cédric !
@RealyUniqueName : Why php.Web.setReturnCode doesn’t that under the hood ?

Probably because php.Web is an old API targetting PHP 5.0+ whereas http_response_code() is available since PHP 5.4…

Hej guys !
There is a minor difference between the old method and php.Global.getallheaders()because it returns all Headers first letter uppercase … I’ve spent all day on this bug ^^

php.Global.getallheaders() is an alias for:

This function returns the raw HTTP headers, whereas php.Web.getClientHeaders() normalizes them.

Normalization is always needed (i.e. convert the array keys either to lowercase or uppercase) because HTTP headers are case-insensitive:

Yes that is what I discovered too.
But first I thought it returns the same thing…