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

Commit 64990cc

Browse files
committed
Implements options
1 parent bb1b936 commit 64990cc

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/Guzzle6HttpAdapter.php

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ public function __construct(Client $client = null)
3737
/**
3838
* {@inheritdoc}
3939
*/
40-
public function sendRequest(RequestInterface $request)
40+
public function sendRequest(RequestInterface $request, array $options = [])
4141
{
42+
$options = $this->buildOptions($options);
43+
4244
try {
43-
return $this->client->send($request);
45+
return $this->client->send($request, $options);
4446
} catch (RequestException $exception) {
4547
throw $this->createException($exception);
4648
}
@@ -49,11 +51,14 @@ public function sendRequest(RequestInterface $request)
4951
/**
5052
* {@inheritdoc}
5153
*/
52-
public function sendRequests(array $requests)
54+
public function sendRequests(array $requests, array $options = [])
5355
{
56+
$options = $this->buildOptions($options);
57+
5458
$results = Pool::batch(
5559
$this->client,
56-
$requests
60+
$requests,
61+
$options
5762
);
5863

5964
$exceptions = [];
@@ -101,4 +106,23 @@ private function createException(RequestException $exception)
101106

102107
return $adapterException;
103108
}
109+
110+
/**
111+
* Builds options for Guzzle
112+
*
113+
* @param array $options
114+
*
115+
* @return array
116+
*/
117+
private function buildOptions(array $options)
118+
{
119+
$guzzleOptions = [];
120+
121+
if (isset($options['timeout'])) {
122+
$guzzleOptions['connect_timeout'] = $options['timeout'];
123+
$guzzleOptions['timeout'] = $options['timeout'];
124+
}
125+
126+
return $guzzleOptions;
127+
}
104128
}

0 commit comments

Comments
 (0)