File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ class Curl {
4
4
5
5
private $ _cookies = array ();
6
6
private $ _headers = array ();
7
+ private $ _options = array ();
7
8
8
9
private $ _multi_parent = FALSE ;
9
10
private $ _multi_child = FALSE ;
@@ -65,6 +66,12 @@ public function get($url_mixed, $data=array()) {
65
66
}
66
67
}
67
68
69
+ foreach ($ this ->curls as $ ch ) {
70
+ foreach ($ this ->_options as $ key => $ value ) {
71
+ $ ch ->setOpt ($ key , $ value );
72
+ }
73
+ }
74
+
68
75
do {
69
76
$ status = curl_multi_exec ($ curl_multi , $ active );
70
77
} while ($ status === CURLM_CALL_MULTI_PERFORM || $ active );
@@ -132,6 +139,7 @@ public function setCookie($key, $value) {
132
139
133
140
public function setOpt ($ option , $ value , $ _ch =NULL ) {
134
141
$ ch = is_null ($ _ch ) ? $ this ->curl : $ _ch ;
142
+ $ this ->_options [$ option ] = $ value ;
135
143
return curl_setopt ($ ch , $ option , $ value );
136
144
}
137
145
Original file line number Diff line number Diff line change @@ -298,6 +298,22 @@ public function testParallelRequests() {
298
298
$ this ->assertTrue (substr ($ curl ->curls ['2 ' ]->response , - $ len ) === '/c/?foo=bar ' );
299
299
}
300
300
301
+ public function testParallelSetOptions () {
302
+ $ curl = new Curl ();
303
+ $ curl ->setHeader ('X-DEBUG-TEST ' , 'server ' );
304
+ $ curl ->setOpt (CURLOPT_SSL_VERIFYPEER , FALSE );
305
+ $ curl ->setOpt (CURLOPT_SSL_VERIFYHOST , FALSE );
306
+ $ curl ->setOpt (CURLOPT_USERAGENT , 'useragent ' );
307
+ $ curl ->complete (function ($ instance ) {
308
+ PHPUnit_Framework_Assert::assertTrue ($ instance ->response === 'useragent ' );
309
+ });
310
+ $ curl ->get (array (
311
+ Test::TEST_URL ,
312
+ ), array (
313
+ 'key ' => 'HTTP_USER_AGENT ' ,
314
+ ));
315
+ }
316
+
301
317
public function testSuccessCallback () {
302
318
$ success_called = FALSE ;
303
319
$ error_called = FALSE ;
You can’t perform that action at this time.
0 commit comments