Add test for Curl::getResponseCookies()

This commit is contained in:
Zach Borboa
2016-02-05 02:52:22 -08:00
parent 561bf6e32f
commit 6214b87670
2 changed files with 6 additions and 2 deletions
+2 -2
View File
@@ -445,8 +445,8 @@ class Curl
*/
public function headerCallback($ch, $header)
{
if (preg_match('/^Set-Cookie:\s*([^=]+)=([^;]+)/mi', $header, $cookie) == 1) {
$this->responseCookies[$cookie[1]] = $cookie[2];
if (preg_match('/^Set-Cookie:\s*([^=]+)=([^;]+)/mi', $header, $cookie) === 1) {
$this->responseCookies[$cookie[1]] = trim($cookie[2], " \n\r\t\0\x0B");
}
$this->rawResponseHeaders .= $header;
return strlen($header);
+4
View File
@@ -753,6 +753,10 @@ class CurlTest extends PHPUnit_Framework_TestCase
$test = new Test();
$test->server('multiple_cookie', 'GET');
$this->assertEquals('cookie1=scrumptious,cookie2=mouthwatering', $test->curl->responseHeaders['Set-Cookie']);
$response_cookies = $test->curl->getResponseCookies();
$this->assertEquals('scrumptious', $response_cookies['cookie1']);
$this->assertEquals('mouthwatering', $response_cookies['cookie2']);
}
public function testDefaultTimeout()