@@ -59,21 +59,24 @@ protected function getResponse():HTTPResponseInterface{
5959 $ this ->responseHeaders = new \stdClass ;
6060
6161 $ headers = $ this ->normalizeRequestHeaders ($ this ->requestHeaders );
62- $ options = [CURLOPT_CUSTOMREQUEST => $ this ->requestMethod ];
6362
64- if (in_array ($ this ->requestMethod , ['PATCH ' , 'POST ' , 'PUT ' , 'DELETE ' ], true )){
63+ if (in_array ($ this ->requestMethod , ['PATCH ' , 'POST ' , 'PUT ' , 'DELETE ' ])){
6564
66- if ($ this ->requestMethod === 'POST ' ){
67- $ options = [CURLOPT_POST => true ];
65+ $ options = in_array ($ this ->requestMethod , ['PATCH ' , 'PUT ' , 'DELETE ' ])
66+ ? [CURLOPT_CUSTOMREQUEST => $ this ->requestMethod ]
67+ : [CURLOPT_POST => true ];
6868
69- if (! isset ( $ headers [ ' Content-type ' ]) && is_array ( $ this -> requestBody )){
70- $ headers += ['Content-type: application/x-www-form-urlencoded ' ];
71- $ this -> requestBody = http_build_query ( $ this -> requestBody , '' , ' & ' , PHP_QUERY_RFC1738 ) ;
72- }
69+
70+ if (! isset ( $ headers ['Content-type ' ]) && $ this -> requestMethod === ' POST ' && is_array ( $ this -> requestBody )){
71+ $ headers += [ ' Content-type: application/x-www-form-urlencoded ' ] ;
72+ $ this -> requestBody = http_build_query ( $ this -> requestBody , '' , ' & ' , PHP_QUERY_RFC1738 );
7373 }
7474
7575 $ options += [CURLOPT_POSTFIELDS => $ this ->requestBody ];
7676 }
77+ else {
78+ $ options = [CURLOPT_CUSTOMREQUEST => $ this ->requestMethod ];
79+ }
7780
7881 $ headers += [
7982 'Host: ' .$ this ->parsedURL ['host ' ],
@@ -90,12 +93,16 @@ protected function getResponse():HTTPResponseInterface{
9093
9194 curl_setopt_array ($ this ->http , $ options );
9295
93- $ response = curl_exec ($ this ->http );
96+ $ response = curl_exec ($ this ->http );
97+ $ curl_info = curl_getinfo ($ this ->http );
98+
99+ curl_close ($ this ->http );
94100
95101 return new HTTPResponse ([
96- 'url ' => $ url ,
97- 'headers ' => $ this ->responseHeaders ,
98- 'body ' => $ response ,
102+ 'url ' => $ url ,
103+ 'curl_info ' => $ curl_info ,
104+ 'headers ' => $ this ->responseHeaders ,
105+ 'body ' => $ response ,
99106 ]);
100107 }
101108
0 commit comments