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


PHP Sabre_HTTP_Request::getHeaders方法代码示例

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


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

示例1: exec

 /**
  * Starts the DAV Server
  *
  * @return void
  */
 public function exec()
 {
     try {
         // If nginx (pre-1.2) is used as a proxy server, and SabreDAV as an
         // origin, we must make sure we send back HTTP/1.0 if this was
         // requested.
         // This is mainly because nginx doesn't support Chunked Transfer
         // Encoding, and this forces the webserver SabreDAV is running on,
         // to buffer entire responses to calculate Content-Length.
         $this->httpResponse->defaultHttpVersion = $this->httpRequest->getHTTPVersion();
         $get_header = $this->httpRequest->getHeaders();
         //if(isset($get_header['tide']))
         //$tide_method = $get_header['tide'];
         $tide_method = isset($get_header['tide']) ? $get_header['tide'] : false;
         $http_method = $this->httpRequest->getMethod();
         if ($tide_method) {
             $http_method = $tide_method;
         }
         $this->invokeMethod($http_method, $this->getRequestUri());
     } catch (Exception $e) {
         try {
             $this->broadcastEvent('exception', array($e));
         } catch (Exception $ignore) {
         }
         $DOM = new DOMDocument('1.0', 'utf-8');
         $DOM->formatOutput = true;
         $error = $DOM->createElementNS('DAV:', 'd:error');
         $error->setAttribute('xmlns:s', self::NS_SABREDAV);
         $DOM->appendChild($error);
         $h = function ($v) {
             return htmlspecialchars($v, ENT_NOQUOTES, 'UTF-8');
         };
         $error->appendChild($DOM->createElement('s:exception', $h(get_class($e))));
         $error->appendChild($DOM->createElement('s:message', $h($e->getMessage())));
         if ($this->debugExceptions) {
             $error->appendChild($DOM->createElement('s:file', $h($e->getFile())));
             $error->appendChild($DOM->createElement('s:line', $h($e->getLine())));
             $error->appendChild($DOM->createElement('s:code', $h($e->getCode())));
             $error->appendChild($DOM->createElement('s:stacktrace', $h($e->getTraceAsString())));
         }
         if (self::$exposeVersion) {
             $error->appendChild($DOM->createElement('s:sabredav-version', $h(Sabre_DAV_Version::VERSION)));
         }
         if ($e instanceof Sabre_DAV_Exception) {
             $httpCode = $e->getHTTPCode();
             $e->serialize($this, $error);
             $headers = $e->getHTTPHeaders($this);
         } else {
             $httpCode = 500;
             $headers = array();
         }
         $headers['Content-Type'] = 'application/xml; charset=utf-8';
         $this->httpResponse->sendStatus($httpCode);
         $this->httpResponse->setHeaders($headers);
         $this->httpResponse->sendBody($DOM->saveXML());
     }
 }
开发者ID:adamchau,项目名称:teamdisk,代码行数:62,代码来源:Server.php

示例2: testGetHeaders

 function testGetHeaders()
 {
     $expected = array('host' => 'www.example.org', 'content-type' => 'text/xml');
     $this->assertEquals($expected, $this->request->getHeaders());
 }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:5,代码来源:RequestTest.php


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