Custon headers not working on php 5.6 - apache 2.4, debian 8 jessie

1.4k views Asked by At

I just upgraded my debian 7 wheezy to debian 8 jessie. Apache and php were updated accordingly from apache 2.2.22 to 2.4.10 and from php 5.4.x to 5.6.9. Now when sending custom headers with ajax request, they are not present in php. Here is a simple example with index.php and ajax.php files with the following contents respectively.

<html>
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                $(document).bind("ajaxSend", function(elm, xhr, s){
                    xhr.setRequestHeader('MY_HEADER', 'my_header_value');
                });

                $.ajax({
                    type : "POST",
                    url : 'ajax.php',
                    data : {},
                    error : function() {
                        alert('error');
                    },
                    success : function(data) {
                        alert(data);
                    }
                });

            });
        </script>
    </head>

    <body>
        <?php //phpinfo();?>
    </body>
</html>

and

<?php 
    if (isset($_SERVER['HTTP_MY_HEADER'])) {
        echo $_SERVER['HTTP_MY_HEADER'];die;
    }

    print_r($_SERVER);
?>

In $_SERVER the HTTP_MY_HEADER is not present.

I have tried this example in my another server with debian 7 with apache 2.2 and php 5.4 and it works fine - the header is set. But for the upgraded version it does not.

Mod headers is enabled and apache is restarted.

Thanks

1

There are 1 answers

1
mmm On BEST ANSWER

what are these headers ? if it's header with underscore, this difference comme from Apache 2.4 :

Header names with underscores ignored in php 5.5.1 / apache 2.4.6