本文整理汇总了PHP中Sabre\HTTP\Request::getHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getHeader方法的具体用法?PHP Request::getHeader怎么用?PHP Request::getHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sabre\HTTP\Request
的用法示例。
在下文中一共展示了Request::getHeader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseUserPass
public static function parseUserPass(HTTP\Request $httpRequest)
{
// Apache and mod_php
if ($user = $httpRequest->getRawServerValue('PHP_AUTH_USER')) {
$pass = "";
if ($passw = $httpRequest->getRawServerValue('PHP_AUTH_PW')) {
$pass = $passw;
}
return array($user, $pass);
}
// Most other webservers
$auth = $httpRequest->getHeader('Authorization');
// Apache could prefix environment variables with REDIRECT_ when urls
// are passed through mod_rewrite
if (!$auth) {
$auth = $httpRequest->getRawServerValue('REDIRECT_HTTP_AUTHORIZATION');
}
if (!$auth) {
return false;
}
if (strpos(strtolower($auth), 'basic') !== 0) {
return false;
}
return explode(':', base64_decode(substr($auth, 6)), 2);
}
示例2: checkJmapAuth
/**
*
*/
public static function checkJmapAuth(Request $request, AuthenticatedIdentity &$identity = null)
{
// check authentication status
$token = $request->getHeader('Authorization');
if (empty($token)) {
return 401;
}
// cut off authorization scheme
$token = preg_replace('/^X-JMAP\\s+/', '', $token);
// load session data for the given auth token
$session = App::getInstance()->get('Session');
$session->start($token);
if (empty($session->get('Auth\\authenticated'))) {
return 401;
}
// load identity from session
$identity = $session->get('Auth\\identity');
return 200;
}