-
-
Save katzueno/2a625aa8369a3afdade3a0119dc1b096 to your computer and use it in GitHub Desktop.
concrete5 header tester
This file contains 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
// application/bootstrap/app.php | |
Route::register('/ccm/request', function() { | |
header("Pragma: no-cache"); | |
header("Pragma: no-cache"); | |
echo '<dl>'; | |
$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication(); | |
?><dt>Application environment:</dt><dd><?php echo ($app->environment()) ? $app->environment() : 'default'; ?></dd><?php | |
$request = \Concrete\Core\Http\Request::getInstance(); | |
?><dt>Client IP:</dt><dd><?php echo $request->getClientIp(); ?></dd><?php | |
?><dt>Host:</dt><dd><?php echo $request->getHost(); ?></dd><?php | |
?><dt>Port:</dt><dd><?php echo $request->getPort(); ?></dd><?php | |
?><dt>Scheme:</dt><dd><?php echo $request->getScheme(); ?></dd><?php | |
?><dt>Secure:</dt><dd><?php echo ($request->isSecure()) ? 'true' : 'false'; ?></dd><?php | |
?><dt>Canonical URL:</dt><dd><?php echo \Core::make('url/canonical'); ?></dd><?php | |
?><dt>Get all headers:</dt><dd><pre><?php var_dump(c5getallheaders()); ?></pre></dd><?php | |
echo '</dl>'; | |
}); | |
function c5getallheaders() | |
{ | |
$headers = ''; | |
foreach ($_SERVER as $name => $value) | |
{ | |
$headers[$name] = $value; | |
} | |
return $headers; | |
} | |
/* | |
if(!function_exists('getallheaders')) | |
{ | |
// This is for nginx server which doesn't support getallheaders(); | |
function getallheaders() | |
{ | |
$headers = ''; | |
foreach ($_SERVER as $name => $value) | |
{ | |
if(substr($name, 0, 5) == 'HTTP_') | |
{ | |
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; | |
} | |
} | |
return $headers; | |
} | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment