本文整理汇总了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);
}