mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-03 14:27:59 +00:00
Encode cookies per RFC 3986
This commit is contained in:
+1
-1
@@ -204,7 +204,7 @@ class Curl
|
||||
public function setCookie($key, $value)
|
||||
{
|
||||
$this->cookies[$key] = $value;
|
||||
$this->setOpt(CURLOPT_COOKIE, http_build_query($this->cookies, '', '; '));
|
||||
$this->setOpt(CURLOPT_COOKIE, http_build_query($this->cookies, '', '; ', PHP_QUERY_RFC3986));
|
||||
}
|
||||
|
||||
public function setCookieFile($cookie_file)
|
||||
|
||||
@@ -331,6 +331,18 @@ class CurlTest extends PHPUnit_Framework_TestCase
|
||||
)) === 'yum');
|
||||
}
|
||||
|
||||
public function testCookieEncoding()
|
||||
{
|
||||
$curl = new Curl();
|
||||
$curl->setCookie('cookie', 'Om nom nom nom');
|
||||
|
||||
$reflectionClass = new ReflectionClass('\Curl\Curl');
|
||||
$reflectionProperty = $reflectionClass->getProperty('options');
|
||||
$reflectionProperty->setAccessible(true);
|
||||
$options = $reflectionProperty->getValue($curl);
|
||||
$this->assertEquals('cookie=Om%20nom%20nom%20nom', $options[CURLOPT_COOKIE]);
|
||||
}
|
||||
|
||||
public function testCookieFile()
|
||||
{
|
||||
$cookie_file = dirname(__FILE__) . '/cookies.txt';
|
||||
|
||||
Reference in New Issue
Block a user