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


PHP Zend_Controller_Request_Http::getHeader方法代码示例

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


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

示例1: authenticate

 /**
  * Performs an authentication attempt
  *
  * @throws Zend_Auth_Adapter_Exception If authentication cannot be performed
  * @return Zend_Auth_Result
  */
 public function authenticate()
 {
     if (empty($this->_request) || empty($this->_response)) {
         require_once 'Zend/Auth/Adapter/Exception.php';
         throw new Zend_Auth_Adapter_Exception('Request and Response objects must be set before calling ' . 'authenticate()');
     }
     $header = $this->_request->getHeader('Authorization');
     if (empty($header)) {
         return $this->_challengeClient();
     }
     $parts = array_filter(explode(' ', $header));
     if ($parts < 2) {
         return $this->_challengeClient();
     }
     $scheme = array_shift($parts);
     $creds = implode(' ', $parts);
     if (empty($this->_schemes[$scheme])) {
         throw new Zend_Auth_Adapter_Exception('Unsupported authentication scheme (' . $scheme . ')');
     }
     $result = call_user_func($this->_schemes[$scheme], trim($creds), $this->_request);
     if (empty($result)) {
         \App::log()->debug("Authentication failed using scheme: " . @$this->_schemes[$scheme]);
         \App::log()->debug("Authentication failed using creds: " . @$creds);
         return $this->_challengeClient();
     } else {
         if ($result instanceof Zend_Auth_Result) {
             return $result;
         } else {
             return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $result);
         }
     }
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:38,代码来源:M2m.php

示例2: _getAuthToken

 /**
  * Get api id from TransactionInfo header
  *
  * @return string
  */
 protected function _getAuthToken()
 {
     $token = $this->_request->getHeader(static::HEADER);
     if (empty($token)) {
         throw new Zend_Auth_Adapter_Exception("M2M-3rdparty-token header is missing");
     }
     return $token;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:13,代码来源:ThirdParty.php

示例3: testGetHeaderThrowsExceptionWithNoInput

 public function testGetHeaderThrowsExceptionWithNoInput()
 {
     try {
         // Suppressing warning
         $header = @$this->_request->getHeader();
         $this->fail('getHeader() should fail with no arguments)');
     } catch (Exception $e) {
         // success
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:10,代码来源:HttpTest.php

示例4: getHeader

 /**
  * {@inheritdoc}
  *
  * Added CGI environment support.
  */
 public function getHeader($header)
 {
     $headerValue = parent::getHeader($header);
     if ($headerValue == false) {
         /** Workaround for php-fpm environment */
         $header = strtoupper(str_replace('-', '_', $header));
         if (isset($_SERVER[$header]) && in_array($header, ['CONTENT_TYPE', 'CONTENT_LENGTH'])) {
             $headerValue = $_SERVER[$header];
         }
     }
     return $headerValue;
 }
开发者ID:,项目名称:,代码行数:17,代码来源:

示例5: _getAccessToken

 protected function _getAccessToken()
 {
     $request = new Zend_Controller_Request_Http();
     $authorization = $request->getHeader('authorization');
     if ($authorization) {
         $token = explode(' ', $authorization);
         $token = $token[1];
         if (isset($token) && is_string($token)) {
             return $token;
         }
         Mage::throwException($this->__('Authentication header format is invalid.'));
     }
     Mage::throwException($this->__('Authentication header is absent.'));
 }
开发者ID:jgermade,项目名称:magento,代码行数:14,代码来源:PaymentController.php

示例6: _getApiId

 /**
  * Get api id from TransactionInfo header
  *
  * @return string
  */
 protected function _getApiId()
 {
     // Get the API Id and try to obtain organization Id mapping
     $transactionInfo = $this->_request->getHeader('TransactionInfo');
     if (empty($transactionInfo)) {
         throw new Zend_Auth_Adapter_Exception("TransactionInfo header is missing");
     }
     if (!preg_match('/appid=\\"(?P<apiId>[^\\"]+)\\"/', $transactionInfo, $matches)) {
         throw new Zend_Auth_Adapter_Exception("TransactionInfo appid parameter is missing");
     }
     $apiId = (string) $matches['apiId'];
     if (empty($apiId)) {
         throw new Zend_Auth_Adapter_Exception("TransactionInfo appid parameter is empty");
     }
     return $apiId;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:21,代码来源:External.php

示例7: _chequearKey

 /**
  * Autoriza el servicio
  */
 protected function _chequearKey()
 {
     $request = new Request();
     $parametros = $request->getParametros();
     $key_public = $this->_zend_request->getHeader("X-Public");
     $hash_private = $this->_zend_request->getHeader("X-Hash");
     $content = json_encode($parametros);
     $servicio = $this->_DAOService->getByPublicKey($key_public);
     if (!is_null($servicio)) {
         $hash = hash_hmac('sha256', $content, $servicio->key_private);
         if ($hash != $hash_private) {
             $this->_autorizado = false;
         }
     } else {
         $this->_autorizado = false;
     }
 }
开发者ID:CarlosAyala,项目名称:midas-codeigniter-modulo-emergencias,代码行数:20,代码来源:Abstract.php

示例8: match

 /**
  * Match the user submitted path.
  * 
  * Via Omeka_Application_Resource_Router, this is the only available route 
  * for API requests.
  * 
  * @throws Omeka_Controller_Exception_Api
  * @param Zend_Controller_Request_Http $request
  * @return array|false
  */
 public function match($request)
 {
     $front = Zend_Controller_Front::getInstance();
     // Extract URL components.
     preg_match('#^/api/([a-z_]+)(.+)?$#', $request->getPathInfo(), $matches);
     if (!$matches) {
         return false;
     }
     // Throw an error if a key was given but there is no user identity.
     if (isset($_GET['key']) && !Zend_Auth::getInstance()->hasIdentity()) {
         throw new Omeka_Controller_Exception_Api('Invalid key.', 403);
     }
     // The API must be enabled.
     if (!get_option('api_enable')) {
         throw new Omeka_Controller_Exception_Api('API is disabled', 403);
     }
     $resource = $matches[1];
     // Extract path parameters. Not to be confused with request parameters.
     $params = array();
     if (isset($matches[2]) && '/' != $matches[2]) {
         $params = explode('/', $matches[2]);
         array_shift($params);
     }
     // Allow clients to override the HTTP method. This is helpful if the
     // server is configured to reject certain methods.
     if (!($method = $request->getHeader('X-HTTP-Method-Override'))) {
         $method = $request->getMethod();
     }
     // Get all available API resources.
     $apiResources = $front->getParam('api_resources');
     // Get and validate resource, record_type, module, controller, and action.
     $resource = $this->_getResource($resource, $apiResources);
     $recordType = $this->_getRecordType($resource, $apiResources);
     $module = $this->_getModule($resource, $apiResources);
     $controller = $this->_getController($resource, $apiResources);
     $action = $this->_getAction($method, $params, $resource, $apiResources);
     // Validate the GET parameters.
     $this->_validateParams($action, $resource, $apiResources);
     // Set the route variables. Namespace the API parameters to prevent
     // collisions with the request parameters.
     $routeVars = array('module' => $module, 'controller' => $controller, 'action' => $action, 'api_resource' => $resource, 'api_record_type' => $recordType, 'api_params' => $params);
     return $routeVars;
 }
开发者ID:lchen01,项目名称:STEdwards,代码行数:53,代码来源:Api.php

示例9: getHeader

 /**
  * Return the value of the given HTTP header. Pass the header name as the
  * plain, HTTP-specified header name. Ex.: Ask for 'Accept' to get the
  * Accept header, 'Accept-Encoding' to get the Accept-Encoding header.
  *
  * @param string $header HTTP header name
  * @return string|false HTTP header value, or false if not found
  * @throws Zend_Controller_Request_Exception
  */
 public function getHeader($header)
 {
     $temp = strtoupper(str_replace('-', '_', $header));
     if (isset($_SERVER['HTTP_' . $temp])) {
         return $_SERVER['HTTP_' . $temp];
     }
     if (strpos($temp, 'CONTENT_') === 0 && isset($_SERVER[$temp])) {
         return $_SERVER[$temp];
     }
     return parent::getHeader($header);
 }
开发者ID:nhp,项目名称:shopware-4,代码行数:20,代码来源:RequestHttp.php

示例10: testGetHeaderWithEmptyValueReturnsEmptyString

 /**
  * @group ZF-10577
  */
 public function testGetHeaderWithEmptyValueReturnsEmptyString()
 {
     $_SERVER['HTTP_X_FOO'] = '';
     $this->assertSame('', $this->_request->getHeader('X-Foo'));
 }
开发者ID:nbcutech,项目名称:o3drupal,代码行数:8,代码来源:HttpTest.php

示例11: output

 /**
  * Отдать файл в поток
  * 
  * @param Zend_Controller_Request_Http $request Объект запроса для поддержки докачки и кеша 304
  * @param string $headersFileName Отображаемое имя файла или null - оставить оргинальное имя
  * @param string $mime MIME-тип или null - определить по расширению
  * @param bool $isAttachment Как вложение - отобразит в браузере окно сохранения файла
  * @param bool $sendMTime Отдавать дату последней модификации
  * @return void
  */
 public function output($request = null, $headersFileName = null, $mime = 'application/octet-stream', $isAttachment = true, $sendMTime = false)
 {
     set_time_limit(0);
     $path = $this->getFullPath();
     $fsize = $this->getSize();
     $fd = @fopen($path, 'rb');
     if ($fsize && $request instanceof Zend_Controller_Request_Http && ($range = $request->getServer('HTTP_RANGE'))) {
         $range = str_replace('bytes=', '', $range);
         $t = explode('-', $range);
         $range = @$t[0] ?: 0;
         //$end = @$t[1] ?: $fsize;
         if (!empty($range)) {
             fseek($fd, $range);
         }
     } else {
         $range = 0;
     }
     $protocol = 'HTTP/1.1';
     if ($request instanceof Zend_Controller_Request_Http && $request->getServer('SERVER_PROTOCOL')) {
         $protocol = $request->getServer('SERVER_PROTOCOL');
     }
     //ob_end_clean();
     $mtime = false;
     if ($sendMTime) {
         $mtime = $this->getModifiedTime();
     }
     //$headersFileNameConv = iconv('CP1251', 'UTF-8', $headersFileName ?: $this->getBaseName());
     $headersFileNameConv = $headersFileName ?: $this->getBaseName();
     if ($isAttachment) {
         header('Content-Disposition: attachment; filename="' . $headersFileNameConv . '"');
     }
     //header('Content-Disposition: ' . ($isAttachment ? 'attachment' : 'inline') . '; filename="' . $headersFileNameConv . '"');
     if (!$mime) {
         $mime = $this->getFileMimeTypeByExt();
     }
     header('Content-Disposition: attachment; filename="' . $headersFileNameConv . '"');
     header('Content-Type: ' . $mime . '; name="' . $headersFileNameConv . '"');
     if ($mtime) {
         $ifModSince = strtotime($request->getHeader('If-Modified-Since'));
         if ($ifModSince >= $mtime) {
             header($protocol . ' 304 Not Modified');
             exit;
         }
     }
     if ($range) {
         header($protocol . ' 206 Partial Content');
     } else {
         header($protocol . ' 200 OK');
     }
     if ($mtime) {
         header('Last-Modified: ' . date('D, d M Y H:i:s T', $mtime));
     }
     header('Content-Transfer-Encoding: binary');
     header('Accept-Ranges: bytes');
     if ($fsize !== false) {
         if ($range) {
             header('Content-Length: ' . ($fsize - $range));
             header("Content-Range: bytes " . $range . "-" . ($fsize - 1) . '/' . $fsize);
         } else {
             header('Content-Length: ' . $fsize);
         }
     }
     ob_end_clean();
     flush();
     //fpassthru($fd);
     while (!feof($fd) && !connection_status()) {
         echo fread($fd, 1048576);
         flush();
     }
     fclose($fd);
     exit;
     /*
     ob_end_clean();
     header('Content-Description: File Transfer');
     header('Content-Type: application/octet-stream');
     header('Content-Disposition: attachment; filename="' . iconv('CP1251', 'UTF-8', basename($path)) . '"');
     header('Content-Transfer-Encoding: binary');
     header('Expires: 0');
     header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     header('Pragma: public');
     $fsize = App_File::getSize($path, true);
     if ($fsize !== false) {
         header('Content-Length: ' . $fsize);
     }
     ob_clean();
     flush();
     readfile($path);
     exit;
     */
 }
开发者ID:slkxmail,项目名称:App,代码行数:100,代码来源:File.php

示例12: __construct

 public function __construct(\Zend_Controller_Request_Http $request)
 {
     $this->request = $request;
     $this->header = new Header($request->getHeader('authorization'));
 }
开发者ID:simgroep,项目名称:oauth1-service,代码行数:5,代码来源:Zf1Request.php

示例13: _fetchParams

 /**
  * Retrieve protocol and request parameters from request object
  *
  * @param string $authHeaderValue
  * @link http://tools.ietf.org/html/rfc5849#section-3.5
  * @return Mage_Oauth_Model_Server
  */
 protected function _fetchParams($authHeaderValue = null)
 {
     if (is_null($authHeaderValue)) {
         $authHeaderValue = $this->_request->getHeader('Authorization');
     }
     if ($authHeaderValue && 'oauth' === strtolower(substr($authHeaderValue, 0, 5))) {
         $authHeaderValue = substr($authHeaderValue, 6);
         // ignore 'OAuth ' at the beginning
         foreach (explode(',', $authHeaderValue) as $paramStr) {
             $nameAndValue = explode('=', trim($paramStr), 2);
             if (count($nameAndValue) < 2) {
                 continue;
             }
             if ($this->_isProtocolParameter($nameAndValue[0])) {
                 $this->_protocolParams[rawurldecode($nameAndValue[0])] = rawurldecode(trim($nameAndValue[1], '"'));
             }
         }
     }
     $contentTypeHeader = $this->_request->getHeader(Zend_Http_Client::CONTENT_TYPE);
     if ($contentTypeHeader && 0 === strpos($contentTypeHeader, Zend_Http_Client::ENC_URLENCODED)) {
         $protocolParamsNotSet = !$this->_protocolParams;
         parse_str($this->_request->getRawBody(), $bodyParams);
         foreach ($bodyParams as $bodyParamName => $bodyParamValue) {
             if (!$this->_isProtocolParameter($bodyParamName)) {
                 $this->_params[$bodyParamName] = $bodyParamValue;
             } elseif ($protocolParamsNotSet) {
                 $this->_protocolParams[$bodyParamName] = $bodyParamValue;
             }
         }
     }
     $protocolParamsNotSet = !$this->_protocolParams;
     $url = $this->_request->getScheme() . '://' . $this->_request->getHttpHost() . $this->_request->getRequestUri();
     if ($queryString = Zend_Uri_Http::fromString($url)->getQuery()) {
         foreach (explode('&', $queryString) as $paramToValue) {
             $paramData = explode('=', $paramToValue);
             if (2 === count($paramData) && !$this->_isProtocolParameter($paramData[0])) {
                 $this->_params[rawurldecode($paramData[0])] = rawurldecode($paramData[1]);
             }
         }
     }
     if ($protocolParamsNotSet) {
         $this->_fetchProtocolParamsFromQuery();
     }
     return $this;
 }
开发者ID:,项目名称:,代码行数:52,代码来源:

示例14: initiate

    public static function initiate($namespace)
    {
        $request = new Zend_Controller_Request_Http();
        $sso = false;
        if ($request->getPathInfo() == '/sso') {
            $sso = true;
            if (isset($_GET['sid'])) {
                Zend_Session::setId($_GET['sid']);
                $referer = $request->getHeader('Referer');
            } elseif (isset($_GET['csid']) && !Zend_Session::sessionExists()) {
                Zend_Session::setId($_GET['csid']);
                $dieGotIt = true;
            }
        }
        Zend_Registry::set('csession', new Zend_Session_Namespace('cosmosclient'));
        Zend_Registry::set('cartsess', new Zend_Session_Namespace($namespace));
        $sessionID = Zend_Session::getId();
        if (isset($dieGotIt) && $dieGotIt == true) {
            die("// Got it: {$sessionID}");
        }
        // Invalid session ID somehow.... Give them one.
        if (Zend_Session::sessionExists() && !Zend_Registry::get('csession')->sessionExists) {
            unset($_COOKIE[session_name()]);
            Zend_Session::regenerateId();
            Zend_Registry::get('csession')->sessionExists = true;
        }
        if (Zend_Session::sessionExists()) {
            if (isset($referer)) {
                header("Location: {$referer}");
                die;
            } elseif ($sso == true && isset($_GET['csid'])) {
                if ($sessionID == $_GET['csid']) {
                    die('// No SID update needed.');
                }
                $cookieName = session_name();
                $js = <<<js
window.stop();
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
setCookie("{$cookieName}","{$sessionID}");
cookieValue = getCookie("{$cookieName}");
if(cookieValue == "{$sessionID}"){
location.reload(true);
} else {
window.location = '/sso?sid={$sessionID}';
}
js;
                die($js);
            }
        } else {
            Zend_Registry::get('csession')->sessionExists = true;
        }
    }
开发者ID:EvanDotPro,项目名称:cosmos,代码行数:73,代码来源:Sso.php

示例15: prepareRequest

 /**
  * Process HTTP request object and prepare for token validation
  *
  * @param \Zend_Controller_Request_Http $httpRequest
  * @return array
  */
 public function prepareRequest($httpRequest)
 {
     $oauthParams = $this->_processRequest($httpRequest->getHeader('Authorization'), $httpRequest->getHeader(\Zend_Http_Client::CONTENT_TYPE), $httpRequest->getRawBody(), $this->getRequestUrl($httpRequest));
     return $oauthParams;
 }
开发者ID:,项目名称:,代码行数:11,代码来源:


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