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


PHP Client::addCookie方法代码示例

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


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

示例1: testIfArrayIteratorOfHeadersCanBeSet

 public function testIfArrayIteratorOfHeadersCanBeSet()
 {
     $headers = new \ArrayIterator(array(new SetCookie('foo'), new SetCookie('bar')));
     $client = new Client();
     $client->addCookie($headers);
     $cookies = $client->getCookies();
     $this->assertEquals(2, count($cookies));
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:8,代码来源:ClientTest.php

示例2: testRawCookiesInRequestHeaders

 /**
  * Test sending cookie header with raw value
  *
  * @group fix-double-encoding-problem-about-cookie-value
  */
 public function testRawCookiesInRequestHeaders()
 {
     $this->_client->setConfig(array('encodecookies' => false));
     $this->_client->addCookie('foo', 'bar=baz');
     $this->_client->send();
     $cookieValue = 'Cookie: foo=bar=baz';
     $this->assertContains($cookieValue, $this->_client->getLastRawRequest(), 'Request is expected to contain the entire cookie "keyname=raw_value"');
 }
开发者ID:navtis,项目名称:xerxes-pazpar2,代码行数:13,代码来源:StaticTest.php

示例3: getClient

 protected function getClient($url)
 {
     $http_client = new HttpClient(null, ['timeout' => $this->timeout]);
     $http_client->setHeaders(['User-Agent' => 'OpenErpByJsonRpc by ZendJsonRpc']);
     if (null !== $this->cookie) {
         $http_client->addCookie($this->cookie);
     }
     $this->client = new Client($url, $http_client);
     return $this->client;
 }
开发者ID:leblanc-simon,项目名称:openerpbyjsonrpc,代码行数:10,代码来源:ZendJsonRpc.php

示例4: testRawCookiesInRequestHeaders

 /**
  * Test sending cookie header with raw value
  *
  * @group fix-double-encoding-problem-about-cookie-value
  */
 public function testRawCookiesInRequestHeaders()
 {
     if (!constant('TESTS_ZEND_HTTP_CLIENT_ONLINE')) {
         $this->markTestSkipped('Zend\\Http\\Client online tests are not enabled');
     }
     $this->_client->setOptions(array('encodecookies' => false));
     $this->_client->addCookie('foo', 'bar=baz');
     $this->_client->send();
     $cookieValue = 'Cookie: foo=bar=baz';
     $this->assertContains($cookieValue, $this->_client->getLastRawRequest(), 'Request is expected to contain the entire cookie "keyname=raw_value"');
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:16,代码来源:StaticTest.php

示例5: testSetInvalidCookies

 /**
  * Make sure using an invalid cookie jar object throws an exception
  *
  */
 public function testSetInvalidCookies()
 {
     $this->setExpectedException('Zend\\Http\\Exception\\InvalidArgumentException', 'Invalid parameter type passed as Cookie');
     $this->_client->addCookie('cookie');
 }
开发者ID:nevvermind,项目名称:zf2,代码行数:9,代码来源:StaticTest.php

示例6: testIfNullValueCookiesThrowsException

 /**
  * @expectedException Zend\Http\Exception\InvalidArgumentException
  */
 public function testIfNullValueCookiesThrowsException()
 {
     $client = new Client();
     $client->addCookie("test", null);
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:8,代码来源:ClientTest.php


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