mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-30 20:20:53 +00:00
+3
-1
@@ -544,7 +544,9 @@ class Curl
|
||||
public function setCookie($key, $value)
|
||||
{
|
||||
$this->cookies[$key] = $value;
|
||||
$this->setOpt(CURLOPT_COOKIE, str_replace(' ', '%20', urldecode(http_build_query($this->cookies, '', '; '))));
|
||||
$this->setOpt(CURLOPT_COOKIE, implode('; ', array_map(function($k, $v) {
|
||||
return $k . '=' . str_replace(' ', '%20', $v);
|
||||
}, array_keys($this->cookies), array_values($this->cookies))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -662,6 +662,19 @@ class CurlTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('cookie=Om%20nom%20nom%20nom', $options[CURLOPT_COOKIE]);
|
||||
}
|
||||
|
||||
public function testMultipleCookies()
|
||||
{
|
||||
$curl = new Curl();
|
||||
$curl->setCookie('cookie', 'Om nom nom nom');
|
||||
$curl->setCookie('foo', 'bar');
|
||||
|
||||
$reflectionClass = new ReflectionClass('\Curl\Curl');
|
||||
$reflectionProperty = $reflectionClass->getProperty('options');
|
||||
$reflectionProperty->setAccessible(true);
|
||||
$options = $reflectionProperty->getValue($curl);
|
||||
$this->assertEquals('cookie=Om%20nom%20nom%20nom; foo=bar', $options[CURLOPT_COOKIE]);
|
||||
}
|
||||
|
||||
public function testCookieEncodingColon()
|
||||
{
|
||||
$curl = new Curl();
|
||||
|
||||
Reference in New Issue
Block a user