當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。