当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::rawHeaders方法代码示例

本文整理汇总了PHP中Slim\Http\Request::rawHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::rawHeaders方法的具体用法?PHP Request::rawHeaders怎么用?PHP Request::rawHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Slim\Http\Request的用法示例。


在下文中一共展示了Request::rawHeaders方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: extractToken

 public function extractToken(Request $request)
 {
     $headers = $request->headers();
     $rawHeaders = $request->rawHeaders();
     if (isset($rawHeaders['Authorization'])) {
         $header = $rawHeaders['Authorization'];
     } elseif (isset($headers['Authorization'])) {
         $header = $headers['Authorization'];
     } else {
         throw new Exception('Authorization header required.');
     }
     if (preg_match('/Basic\\s+(.*)$/i', $header, $matches)) {
         list($authUser, $authPass) = explode(':', base64_decode($matches[1]));
     } else {
         throw new Exception('Authorization header invalid.');
     }
     if (isset($authUser) && isset($authPass)) {
         try {
             $token = $this->fetchToken($authUser, $authPass);
         } catch (\Exception $e) {
             throw new Exception('Authorization header invalid.');
         }
     }
     return $token;
 }
开发者ID:rohanabraham,项目名称:lxHive,代码行数:25,代码来源:Basic.php

示例2: extractToken

 public function extractToken(Request $request)
 {
     $tokenHeader = $request->headers('Authorization', false);
     $rawTokenHeader = $request->rawHeaders('Authorization', false);
     if ($tokenHeader && preg_match('/Bearer\\s*([^\\s]+)/', $tokenHeader, $matches)) {
         $tokenHeader = $matches[1];
     } elseif ($rawTokenHeader && preg_match('/Bearer\\s*([^\\s]+)/', $rawTokenHeader, $matches)) {
         $tokenHeader = $matches[1];
     } else {
         $tokenHeader = false;
     }
     $tokenRequest = $request->post('access_token', false);
     $tokenQuery = $request->get('access_token', false);
     // At least one (and only one) of client credentials method required.
     if (!$tokenHeader && !$tokenRequest && !$tokenQuery) {
         throw new Exception('The request is missing a required parameter.', Resource::STATUS_BAD_REQUEST);
     } elseif ($tokenHeader && $tokenRequest || $tokenRequest && $tokenQuery || $tokenQuery && $tokenHeader) {
         throw new Exception('The request includes multiple credentials.', Resource::STATUS_BAD_REQUEST);
     }
     $accessToken = $tokenHeader ?: $tokenRequest ?: $tokenQuery;
     try {
         $tokenDocument = $this->fetchToken($accessToken);
     } catch (\Exception $e) {
         throw new Exception('Access token invalid.');
     }
     return $tokenDocument;
 }
开发者ID:rohanabraham,项目名称:lxHive,代码行数:27,代码来源:OAuth.php


注:本文中的Slim\Http\Request::rawHeaders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。