@@ -36,30 +36,34 @@ public function send($uri, $payload)
3636 */
3737 public function request ($ uri , $ body , $ headers , $ method )
3838 {
39+ $ processed_headers = array ();
40+ if (!empty ($ headers ))
41+ {
42+ foreach ($ headers as $ key => $ value )
43+ {
44+ $ processed_headers [] = $ key . ': ' . $ value ;
45+ }
46+ }
3947 $ ch = curl_init ();
4048 curl_setopt ($ ch , CURLOPT_URL , $ uri );
4149 curl_setopt ($ ch , CURLOPT_TIMEOUT , 60 );
4250 curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
4351 curl_setopt ($ ch , CURLOPT_HEADER , false );
44- curl_setopt ($ ch , CURLOPT_HTTPHEADER , $ headers );
52+ curl_setopt ($ ch , CURLOPT_HTTPHEADER , $ processed_headers );
4553 curl_setopt ($ ch , CURLOPT_CAINFO , __DIR__ . DIRECTORY_SEPARATOR . '.. ' . DIRECTORY_SEPARATOR . '.. ' . DIRECTORY_SEPARATOR . 'cacert.pem ' );
46-
4754 if ($ method === 'POST ' )
4855 {
4956 curl_setopt ($ ch , CURLOPT_POST , true );
50-
5157 if ($ body && is_array ($ body ))
5258 {
5359 $ body = http_build_query ($ body , '' , '& ' );
5460 }
55-
5661 curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ body );
5762 }
5863 else
5964 {
6065 curl_setopt ($ ch , CURLOPT_CUSTOMREQUEST , $ method );
6166 }
62-
6367 $ response = curl_exec ($ ch );
6468 $ responseCode = curl_getinfo ($ ch , CURLINFO_HTTP_CODE );
6569
0 commit comments