File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,7 @@ Curl::get($url, $data = array())
187
187
Curl::getCookie($key)
188
188
Curl::getOpt($option)
189
189
Curl::getResponseCookie($key)
190
+ Curl::getResponseCookies()
190
191
Curl::head($url, $data = array())
191
192
Curl::headerCallback($ch, $header)
192
193
Curl::options($url, $data = array())
Original file line number Diff line number Diff line change @@ -445,8 +445,8 @@ public function head($url, $data = array())
445
445
*/
446
446
public function headerCallback ($ ch , $ header )
447
447
{
448
- if (preg_match ('/^Set-Cookie:\s*([^=]+)=([^;]+)/mi ' , $ header , $ cookie ) == 1 ) {
449
- $ this ->responseCookies [$ cookie [1 ]] = $ cookie [2 ];
448
+ if (preg_match ('/^Set-Cookie:\s*([^=]+)=([^;]+)/mi ' , $ header , $ cookie ) === 1 ) {
449
+ $ this ->responseCookies [$ cookie [1 ]] = trim ( $ cookie [2 ], " \n\r\t\0\x0B" ) ;
450
450
}
451
451
$ this ->rawResponseHeaders .= $ header ;
452
452
return strlen ($ header );
@@ -632,6 +632,17 @@ public function getResponseCookie($key)
632
632
return isset ($ this ->responseCookies [$ key ]) ? $ this ->responseCookies [$ key ] : null ;
633
633
}
634
634
635
+ /**
636
+ * Get response cookies.
637
+ *
638
+ * @access public
639
+ * @return array
640
+ */
641
+ public function getResponseCookies ()
642
+ {
643
+ return $ this ->responseCookies ;
644
+ }
645
+
635
646
/**
636
647
* Set Port
637
648
*
Original file line number Diff line number Diff line change @@ -753,6 +753,10 @@ public function testMultipleCookieResponse()
753
753
$ test = new Test ();
754
754
$ test ->server ('multiple_cookie ' , 'GET ' );
755
755
$ this ->assertEquals ('cookie1=scrumptious,cookie2=mouthwatering ' , $ test ->curl ->responseHeaders ['Set-Cookie ' ]);
756
+
757
+ $ response_cookies = $ test ->curl ->getResponseCookies ();
758
+ $ this ->assertEquals ('scrumptious ' , $ response_cookies ['cookie1 ' ]);
759
+ $ this ->assertEquals ('mouthwatering ' , $ response_cookies ['cookie2 ' ]);
756
760
}
757
761
758
762
public function testDefaultTimeout ()
You can’t perform that action at this time.
0 commit comments