mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-17 22:06:28 +00:00
Add test for Curl::getResponseCookies()
This commit is contained in:
+2
-2
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user