@@ -43,7 +43,7 @@ class HttpClient implements HttpClientInterface
4343 public function __construct (array $ options = array (), ClientInterface $ client = null )
4444 {
4545 $ this ->options = array_merge ($ this ->options , $ options );
46- $ client = $ client ?: new GuzzleClient ($ this ->options ['base_url ' ], $ this ->options );
46+ $ client = $ client ?: new GuzzleClient ($ this ->options ['base_url ' ], $ this ->options );
4747 $ this ->client = $ client ;
4848
4949 $ this ->addListener ('request.error ' , array (new ErrorListener ($ this ->options ), 'onRequestError ' ));
@@ -127,11 +127,7 @@ public function put($path, array $parameters = array(), array $headers = array()
127127 */
128128 public function request ($ path , array $ parameters = array (), $ httpMethod = 'GET ' , array $ headers = array ())
129129 {
130- $ requestBody = count ($ parameters ) === 0
131- ? null : json_encode ($ parameters , empty ($ parameters ) ? JSON_FORCE_OBJECT : 0 )
132- ;
133-
134- $ request = $ this ->createRequest ($ httpMethod , $ path , $ requestBody , $ headers );
130+ $ request = $ this ->createRequest ($ httpMethod , $ path , $ parameters , $ headers );
135131 $ request ->addHeaders ($ headers );
136132
137133 try {
@@ -174,8 +170,24 @@ public function getLastResponse()
174170 return $ this ->lastResponse ;
175171 }
176172
177- protected function createRequest ($ httpMethod , $ path , $ requestBody , array $ headers = array ())
173+ protected function createRequest ($ httpMethod , $ path , array $ parameters = array () , array $ headers = array ())
178174 {
179- return $ this ->client ->createRequest ($ httpMethod , $ path , array_merge ($ this ->headers , $ headers ), $ requestBody );
175+ if ('GET ' !== $ httpMethod ) {
176+ $ requestBody = count ($ parameters ) === 0
177+ ? null : json_encode ($ parameters , empty ($ parameters ) ? JSON_FORCE_OBJECT : 0 )
178+ ;
179+ $ options = array ();
180+ } else {
181+ $ requestBody = null ;
182+ $ options = array ('query ' => $ parameters );
183+ }
184+
185+ return $ this ->client ->createRequest (
186+ $ httpMethod ,
187+ $ path ,
188+ array_merge ($ this ->headers , $ headers ),
189+ $ requestBody ,
190+ $ options
191+ );
180192 }
181193}
0 commit comments