Skip to content

Instantly share code, notes, and snippets.

@trylik
Created April 28, 2011 06:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trylik/945915 to your computer and use it in GitHub Desktop.
Save trylik/945915 to your computer and use it in GitHub Desktop.
Bypassing apache_request_headers() for phpunit
<?php
function request_headers()
{
if(function_exists("apache_request_headers")) // If apache_request_headers() exists...
{
if($headers = apache_request_headers()) // And works...
{
return $headers; // Use it
}
}
$headers = array();
foreach(array_keys($_SERVER) as $skey)
{
if(substr($skey, 0, 5) == "HTTP_")
{
$headername = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($skey, 0, 5)))));
$headers[$headername] = $_SERVER[$skey];
}
}
return $headers;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment