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


PHP HTTP::request_headers方法代码示例

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


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

示例1: headers

 /**
  * Gets or sets HTTP headers oo the request. All headers
  * are included immediately after the HTTP protocol definition during
  * transmission. This method provides a simple array or key/value
  * interface to the headers.
  *
  * @param   mixed   $key   Key or array of key/value pairs to set
  * @param   string  $value Value to set to the supplied key
  * @return  mixed
  */
 public function headers($key = NULL, $value = NULL)
 {
     if ($key instanceof HTTP_Header) {
         // Act a setter, replace all headers
         $this->_header = $key;
         return $this;
     }
     if (is_array($key)) {
         // Act as a setter, replace all headers
         $this->_header->exchangeArray($key);
         return $this;
     }
     if ($this->_header->count() === 0 and $this->is_initial()) {
         // Lazy load the request headers
         $this->_header = HTTP::request_headers();
     }
     if ($key === NULL) {
         // Act as a getter, return all headers
         return $this->_header;
     } elseif ($value === NULL) {
         // Act as a getter, single header
         return $this->_header->offsetExists($key) ? $this->_header->offsetGet($key) : NULL;
     }
     // Act as a setter for a single header
     $this->_header[$key] = $value;
     return $this;
 }
开发者ID:benshez,项目名称:DreamWeddingCeremomies,代码行数:37,代码来源:Request.php

示例2: test_request_headers

 /**
  * Tests HTTP::request_headers()
  *
  * HTTP::request_headers relies on the $_SERVER superglobal if the function
  * `apache_request_headers` or the PECL `http` extension are not available.
  *
  * The test feeds the $_SERVER superglobal with the test cases' datasets
  * and then restores the $_SERVER superglobal so that it does not affect
  * other tests.
  *
  * @test
  * @dataProvider provider_request_headers
  * @param array  $server_globals      globals to feed $_SERVER
  * @param array  $expected_headers    Expected, cleaned HTTP headers
  */
 public function test_request_headers(array $server_globals, array $expected_headers)
 {
     // save the $_SERVER super-global into temporary local var
     $tmp_server = $_SERVER;
     $_SERVER = array_replace_recursive($_SERVER, $server_globals);
     $headers = HTTP::request_headers();
     $actual_headers = array_intersect_key($headers->getArrayCopy(), $expected_headers);
     $this->assertSame($expected_headers, $actual_headers);
     // revert the super-global to its previous state
     $_SERVER = $tmp_server;
 }
开发者ID:Chinese1904,项目名称:openclassifieds2,代码行数:26,代码来源:HTTPTest.php


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