You are here

public static function RestfulManager::getRequestHttpHeader in RESTful 7

Get the value from an HTTP header.

As Apache may be strict with variables with underscore, we check also the headers directly from Apache, if they are not present in the $_SEVER

Parameters

string $key: The key to use.

string $default_value: The default value to return if no value exists. Defaults to NULL.

Return value

string The value in the HTTP header if exists, other the value of the given "default value".

9 calls to RestfulManager::getRequestHttpHeader()
hook_restful_parse_request_alter in ./restful.api.php
Allow altering the request before it is processed.
RestfulAuthenticationCookie::isCli in plugins/authentication/RestfulAuthenticationCookie.class.php
Detects whether the script is running from a command line environment.
RestfulBase::accessByAllowOrigin in plugins/restful/RestfulBase.php
Checks access based on the referer header and the allow_origin setting.
RestfulBase::getVersionFromRequest in plugins/restful/RestfulBase.php
Gets the major and minor version for the current request.
RestfulHookMenuTestCase::testVersionNegotiation in tests/RestfulHookMenuTestCase.test
Test the version negotiation.

... See full list

File

includes/RestfulManager.php, line 328
Contains \RestfulManager.

Class

RestfulManager
@file Contains \RestfulManager.

Code

public static function getRequestHttpHeader($key, $default_value = NULL) {
  $capital_name = 'HTTP_' . strtoupper(str_replace('-', '_', $key));
  $value = !empty($_SERVER[$capital_name]) ? $_SERVER[$capital_name] : $default_value;
  if (!$value && function_exists('apache_request_headers')) {
    $headers = apache_request_headers();
    $value = !empty($headers[$key]) ? $headers[$key] : $default_value;
  }
  return $value;
}