How do I retrieve the value of a custom header in PHP sent over AJAX?
I have a cross-domain AJAX request which sends blob data, like so:
var blob = new Blob([req.response], {type: "application/octet-stream"});
req = new XMLHttpRequest();
req.open("POST", ws_path(other_context, 'receive_pkg'), true);
req.setRequestHeader('secret', 'some hedaer value'); //<-- custom header
req.onload = function (oEvent) { alert(req.response); };
req.send(blob);
But in my PHP, when I inspect getallheaders()
, I just get (most headers removed for brevity):
...
Access-Control-Request-Method = POST
Access-Control-Request-Headers = content-type,secret
...
My custom header, 'secret', is mentioned in a com-sep list of headers under 'Access-Control-Request-Headers'. But how do I get its actual value?
This question seems to be discussing the same thing, but doesn't cover retrieval.