Ejemplo n.º 1
0
 /**
  * If HTTP_AUTHORIZATION does not exist tries to get it from
  * getallheaders() when available.
  *
  * @param Environment $environment The Slim application Environment
  *
  * @return Environment
  */
 public static function determineAuthorization(Environment $environment)
 {
     $authorization = $environment->get('HTTP_AUTHORIZATION');
     if (null === $authorization && is_callable('getallheaders')) {
         $headers = getallheaders();
         $headers = array_change_key_case($headers, CASE_LOWER);
         if (isset($headers['authorization'])) {
             $environment->set('HTTP_AUTHORIZATION', $headers['authorization']);
         }
     }
     return $environment;
 }