@@ -97,6 +97,8 @@ public function __construct(ConfigurationInterface $configuration = null, Logger
9797 }
9898
9999 $ this ->http_response = 200 ;
100+
101+ $ this ->curl = curl_init ();
100102 }
101103
102104 /**
@@ -178,7 +180,8 @@ public function exec($context, $post_data = null, $custom_request = null, $cooki
178180 $ this ->log ->info ("Curl $ custom_request: $ url JsonData= " .json_encode ($ post_data , JSON_UNESCAPED_UNICODE ));
179181 }
180182
181- $ ch = curl_init ();
183+ curl_reset ($ this ->curl );
184+ $ ch = $ this ->curl ;
182185 curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
183186 curl_setopt ($ ch , CURLOPT_URL , $ url );
184187
@@ -228,7 +231,6 @@ public function exec($context, $post_data = null, $custom_request = null, $cooki
228231 if (!$ response ) {
229232 $ this ->http_response = curl_getinfo ($ ch , CURLINFO_HTTP_CODE );
230233 $ body = curl_error ($ ch );
231- curl_close ($ ch );
232234
233235 /*
234236 * 201: The request has been fulfilled, resulting in the creation of a new resource.
@@ -248,8 +250,6 @@ public function exec($context, $post_data = null, $custom_request = null, $cooki
248250 // if request was ok, parsing http response code.
249251 $ this ->http_response = curl_getinfo ($ ch , CURLINFO_HTTP_CODE );
250252
251- curl_close ($ ch );
252-
253253 // don't check 301, 302 because setting CURLOPT_FOLLOWLOCATION
254254 if ($ this ->http_response != 200 && $ this ->http_response != 201 ) {
255255 throw new JiraException ('CURL HTTP Request Failed: Status Code : '
@@ -271,7 +271,8 @@ public function exec($context, $post_data = null, $custom_request = null, $cooki
271271 */
272272 private function createUploadHandle ($ url , $ upload_file )
273273 {
274- $ ch = curl_init ();
274+ curl_reset ($ this ->curl );
275+ $ ch = $ this ->curl ;
275276 curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
276277 curl_setopt ($ ch , CURLOPT_URL , $ url );
277278
@@ -414,7 +415,6 @@ protected function closeCURLHandle(array $chArr, $mh, $body, $result_code)
414415 foreach ($ chArr as $ ch ) {
415416 $ this ->log ->debug ('CURL Close handle.. ' );
416417 curl_multi_remove_handle ($ mh , $ ch );
417- curl_close ($ ch );
418418 }
419419 $ this ->log ->debug ('CURL Multi Close handle.. ' );
420420 curl_multi_close ($ mh );
@@ -528,7 +528,8 @@ public function download($url, $outDir, $file, $cookieFile = null)
528528 {
529529 $ file = fopen ($ outDir .DIRECTORY_SEPARATOR .$ file , 'w ' );
530530
531- $ ch = curl_init ();
531+ curl_reset ($ this ->curl );
532+ $ ch = $ this ->curl ;
532533 curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
533534 curl_setopt ($ ch , CURLOPT_URL , $ url );
534535
@@ -558,7 +559,6 @@ public function download($url, $outDir, $file, $cookieFile = null)
558559 if (!$ response ) {
559560 $ this ->http_response = curl_getinfo ($ ch , CURLINFO_HTTP_CODE );
560561 $ body = curl_error ($ ch );
561- curl_close ($ ch );
562562 fclose ($ file );
563563
564564 /*
@@ -578,8 +578,6 @@ public function download($url, $outDir, $file, $cookieFile = null)
578578 } else {
579579 // if request was ok, parsing http response code.
580580 $ this ->http_response = curl_getinfo ($ ch , CURLINFO_HTTP_CODE );
581-
582- curl_close ($ ch );
583581 fclose ($ file );
584582
585583 // don't check 301, 302 because setting CURLOPT_FOLLOWLOCATION
0 commit comments