Skip to content
This repository was archived by the owner on Jan 16, 2018. It is now read-only.

Commit 337b3ea

Browse files
committed
Merge pull request #10 from php-http/expose-underlying-client
expose underlying HttpClient methods in HttpMethodsClient
2 parents 7ba30ce + 30a166a commit 337b3ea

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

src/HttpMethodsClient.php

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Http\Client\Exception;
66
use Http\Client\HttpClient;
77
use Http\Message\MessageFactory;
8+
use Psr\Http\Message\RequestInterface;
89
use Psr\Http\Message\ResponseInterface;
910
use Psr\Http\Message\StreamInterface;
1011
use Psr\Http\Message\UriInterface;
@@ -18,10 +19,12 @@
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

Comments
 (0)