本文整理匯總了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));
}
示例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"');
}
示例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;
}
示例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"');
}
示例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');
}
示例6: testIfNullValueCookiesThrowsException
/**
* @expectedException Zend\Http\Exception\InvalidArgumentException
*/
public function testIfNullValueCookiesThrowsException()
{
$client = new Client();
$client->addCookie("test", null);
}