@@ -59,21 +59,24 @@ protected function getResponse():HTTPResponseInterface{
59
59
$ this ->responseHeaders = new \stdClass ;
60
60
61
61
$ headers = $ this ->normalizeRequestHeaders ($ this ->requestHeaders );
62
- $ options = [CURLOPT_CUSTOMREQUEST => $ this ->requestMethod ];
63
62
64
- if (in_array ($ this ->requestMethod , ['PATCH ' , 'POST ' , 'PUT ' , 'DELETE ' ], true )){
63
+ if (in_array ($ this ->requestMethod , ['PATCH ' , 'POST ' , 'PUT ' , 'DELETE ' ])){
65
64
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 ];
68
68
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 );
73
73
}
74
74
75
75
$ options += [CURLOPT_POSTFIELDS => $ this ->requestBody ];
76
76
}
77
+ else {
78
+ $ options = [CURLOPT_CUSTOMREQUEST => $ this ->requestMethod ];
79
+ }
77
80
78
81
$ headers += [
79
82
'Host: ' .$ this ->parsedURL ['host ' ],
@@ -90,12 +93,16 @@ protected function getResponse():HTTPResponseInterface{
90
93
91
94
curl_setopt_array ($ this ->http , $ options );
92
95
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 );
94
100
95
101
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 ,
99
106
]);
100
107
}
101
108
0 commit comments