You are here

public static function LingotekOAuthRequestLogger::getAllHeaders in Lingotek Translation 7.5

Same name and namespace in other branches
  1. 7.7 lib/oauth-php/library/LingotekOAuthRequestLogger.php \LingotekOAuthRequestLogger::getAllHeaders()
  2. 7.4 lib/oauth-php/library/LingotekOAuthRequestLogger.php \LingotekOAuthRequestLogger::getAllHeaders()
  3. 7.6 lib/oauth-php/library/LingotekOAuthRequestLogger.php \LingotekOAuthRequestLogger::getAllHeaders()

* helper to try to sort out headers for people who aren't running apache, * or people who are running PHP as FastCGI. * *

Return value

array of request headers as associative array.

3 calls to LingotekOAuthRequestLogger::getAllHeaders()
LingotekOAuthRequest::__construct in lib/oauth-php/library/LingotekOAuthRequest.php
* Construct from the current request. Useful for checking the signature of a request. * When not supplied with any parameters this will use the current request. * *
LingotekOAuthRequestLogger::flush in lib/oauth-php/library/LingotekOAuthRequestLogger.php
* Logs the request to the database, sends any cached output. * Also called on shutdown, to make sure we always log the request being handled.
LingotekOAuthRequestVerifier::requestIsSigned in lib/oauth-php/library/LingotekOAuthRequestVerifier.php
* See if the current request is signed with OAuth * *

File

lib/oauth-php/library/LingotekOAuthRequestLogger.php, line 278

Class

LingotekOAuthRequestLogger
Log OAuth requests

Code

public static function getAllHeaders() {
  $retarr = array();
  $headers = array();
  if (function_exists('apache_request_headers')) {
    $headers = apache_request_headers();
    ksort($headers);
    return $headers;
  }
  else {
    $headers = array_merge($_ENV, $_SERVER);
    foreach ($headers as $key => $val) {

      //we need this header
      if (strpos(strtolower($key), 'content-type') !== FALSE) {
        continue;
      }
      if (strtoupper(substr($key, 0, 5)) != "HTTP_") {
        unset($headers[$key]);
      }
    }
  }

  //Normalize this array to Cased-Like-This structure.
  foreach ($headers as $key => $value) {
    $key = preg_replace('/^HTTP_/i', '', $key);
    $key = str_replace(" ", "-", ucwords(strtolower(str_replace(array(
      "-",
      "_",
    ), " ", $key))));
    $retarr[$key] = $value;
  }
  ksort($retarr);
  return $retarr;
}