55use Http \Client \Exception ;
66use Http \Client \HttpClient ;
77use Http \Message \MessageFactory ;
8+ use Psr \Http \Message \RequestInterface ;
89use Psr \Http \Message \ResponseInterface ;
910use Psr \Http \Message \StreamInterface ;
1011use Psr \Http \Message \UriInterface ;
1819 * ->post('/bar')
1920 * ;
2021 *
22+ * The client also exposes the sendRequest methods of the wrapped HttpClient.
23+ *
2124 * @author Márk Sági-Kazár <[email protected] > 2225 * @author David Buchmann <[email protected] > 2326 */
24- class HttpMethodsClient
27+ class HttpMethodsClient implements HttpClient
2528{
2629 /**
2730 * @var HttpClient
@@ -171,9 +174,9 @@ public function options($uri, array $headers = [], $body = null)
171174 }
172175
173176 /**
174- * Sends a request
177+ * Sends a request with any HTTP method.
175178 *
176- * @param string $method
179+ * @param string $method HTTP method to use.
177180 * @param string|UriInterface $uri
178181 * @param array $headers
179182 * @param string|StreamInterface|null $body
@@ -182,14 +185,34 @@ public function options($uri, array $headers = [], $body = null)
182185 *
183186 * @return ResponseInterface
184187 */
185- protected function send ($ method , $ uri , array $ headers = [], $ body = null )
188+ public function send ($ method , $ uri , array $ headers = [], $ body = null )
186189 {
187- return $ this ->httpClient -> sendRequest ($ this ->messageFactory ->createRequest (
190+ return $ this ->sendRequest ($ this ->messageFactory ->createRequest (
188191 $ method ,
189192 $ uri ,
190193 '1.1 ' ,
191194 $ headers ,
192195 $ body
193196 ));
194197 }
198+
199+ /**
200+ * Forward to the underlying HttpClient.
201+ *
202+ * {@inheritdoc}
203+ */
204+ public function sendRequest (RequestInterface $ request )
205+ {
206+ $ this ->httpClient ->sendRequest ($ request );
207+ }
208+
209+ /**
210+ * Forward to the underlying HttpClient.
211+ *
212+ * {@inheritdoc}
213+ */
214+ public function sendRequests (array $ requests )
215+ {
216+ $ this ->httpClient ->sendRequests ($ requests );
217+ }
195218}
0 commit comments