Header receiving error in PHP server sent via http request

Asked

Viewed 389 times

2

Galera I need your help.

My restfull client application is sending a header called 'Auth' with an authentication token to the PHP server. When I do the tests with a server running on localhost everything works great. However, when I put the same code on the Localweb server doesn’t work, I can’t recover the header, the code below always falls on Else as if I wasn’t sending the header.

 function authenticateApp() {
    $headers =   apache_request_headers();

    if (isset($headers["Authorization"])) {
     //Se o header foi existe faz os teste de autenticação;
    } else {

        //Se não foi passado retorna um código de erro
       //No localhost funciona, no servidor da Localweb sempre cai aqui.   


    }
}

Note: that in both localhost and localweb I am using version 5.6 of PHP. My local machine is Windows and the server is Linux, does it have something to do?

  • of a print_r on the variable $headers and post the return here.

  • Thanks for the comment Hiago Souza, thanks to him I was able to solve.

  • That’s it :) (Y)

1 answer

-1

Problem solved. When giving a print_r in the variable and doing some more tests I realized that the problem only occurred when I named the header as "Authorization" it did not appear in the list of headers, I changed the name and had no more problem.

function authenticateApp() {
$headers =   apache_request_headers();

if (isset($headers["novo_nome"])) {
 //Bastou renomear o header
} else {

    //Se não foi passado retorna um código de erro

}

}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.