Last active
December 14, 2015 00:39
-
-
Save abrahamvegh/5000816 to your computer and use it in GitHub Desktop.
Return received HTTP headers as JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
function normalize_header_name ($name) | |
{ | |
$name = substr($name, 5); | |
$name = str_replace('_', '-', $name); | |
$name = strtolower($name); | |
return $name; | |
} | |
$headers = array(); | |
foreach ($_SERVER as $name => $value) | |
if (preg_match('/^HTTP_/', $name)) $headers[normalize_header_name($name)] = $value; | |
header('Content-type: application/json'); | |
echo json_encode($headers); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment