@@ -102,6 +102,8 @@ public function __construct(ConfigurationInterface $configuration = null, Logger
102102 }
103103
104104 $ this ->http_response = 200 ;
105+
106+ $ this ->curl = curl_init ();
105107 }
106108
107109 /**
@@ -183,7 +185,8 @@ public function exec($context, $post_data = null, $custom_request = null, $cooki
183185 $ this ->log ->info ("Curl $ custom_request: $ url JsonData= " .json_encode ($ post_data , JSON_UNESCAPED_UNICODE ));
184186 }
185187
186- $ ch = curl_init ();
188+ curl_reset ($ this ->curl );
189+ $ ch = $ this ->curl ;
187190 curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
188191 curl_setopt ($ ch , CURLOPT_URL , $ url );
189192
@@ -233,7 +236,6 @@ public function exec($context, $post_data = null, $custom_request = null, $cooki
233236 if (!$ response ) {
234237 $ this ->http_response = curl_getinfo ($ ch , CURLINFO_HTTP_CODE );
235238 $ body = curl_error ($ ch );
236- curl_close ($ ch );
237239
238240 /*
239241 * 201: The request has been fulfilled, resulting in the creation of a new resource.
@@ -253,8 +255,6 @@ public function exec($context, $post_data = null, $custom_request = null, $cooki
253255 // if request was ok, parsing http response code.
254256 $ this ->http_response = curl_getinfo ($ ch , CURLINFO_HTTP_CODE );
255257
256- curl_close ($ ch );
257-
258258 // don't check 301, 302 because setting CURLOPT_FOLLOWLOCATION
259259 if ($ this ->http_response != 200 && $ this ->http_response != 201 ) {
260260 throw new JiraException ('CURL HTTP Request Failed: Status Code : '
@@ -276,7 +276,8 @@ public function exec($context, $post_data = null, $custom_request = null, $cooki
276276 */
277277 private function createUploadHandle ($ url , $ upload_file )
278278 {
279- $ ch = curl_init ();
279+ curl_reset ($ this ->curl );
280+ $ ch = $ this ->curl ;
280281 curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
281282 curl_setopt ($ ch , CURLOPT_URL , $ url );
282283
@@ -419,7 +420,6 @@ protected function closeCURLHandle(array $chArr, $mh, $body, $result_code)
419420 foreach ($ chArr as $ ch ) {
420421 $ this ->log ->debug ('CURL Close handle.. ' );
421422 curl_multi_remove_handle ($ mh , $ ch );
422- curl_close ($ ch );
423423 }
424424 $ this ->log ->debug ('CURL Multi Close handle.. ' );
425425 curl_multi_close ($ mh );
@@ -533,7 +533,8 @@ public function download($url, $outDir, $file, $cookieFile = null)
533533 {
534534 $ file = fopen ($ outDir .DIRECTORY_SEPARATOR .$ file , 'w ' );
535535
536- $ ch = curl_init ();
536+ curl_reset ($ this ->curl );
537+ $ ch = $ this ->curl ;
537538 curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
538539 curl_setopt ($ ch , CURLOPT_URL , $ url );
539540
@@ -563,7 +564,6 @@ public function download($url, $outDir, $file, $cookieFile = null)
563564 if (!$ response ) {
564565 $ this ->http_response = curl_getinfo ($ ch , CURLINFO_HTTP_CODE );
565566 $ body = curl_error ($ ch );
566- curl_close ($ ch );
567567 fclose ($ file );
568568
569569 /*
@@ -583,8 +583,6 @@ public function download($url, $outDir, $file, $cookieFile = null)
583583 } else {
584584 // if request was ok, parsing http response code.
585585 $ this ->http_response = curl_getinfo ($ ch , CURLINFO_HTTP_CODE );
586-
587- curl_close ($ ch );
588586 fclose ($ file );
589587
590588 // don't check 301, 302 because setting CURLOPT_FOLLOWLOCATION
0 commit comments