This repository was archived by the owner on Jan 6, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +28
-4
lines changed Expand file tree Collapse file tree 1 file changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -37,10 +37,12 @@ public function __construct(Client $client = null)
37
37
/**
38
38
* {@inheritdoc}
39
39
*/
40
- public function sendRequest (RequestInterface $ request )
40
+ public function sendRequest (RequestInterface $ request, array $ options = [] )
41
41
{
42
+ $ options = $ this ->buildOptions ($ options );
43
+
42
44
try {
43
- return $ this ->client ->send ($ request );
45
+ return $ this ->client ->send ($ request, $ options );
44
46
} catch (RequestException $ exception ) {
45
47
throw $ this ->createException ($ exception );
46
48
}
@@ -49,11 +51,14 @@ public function sendRequest(RequestInterface $request)
49
51
/**
50
52
* {@inheritdoc}
51
53
*/
52
- public function sendRequests (array $ requests )
54
+ public function sendRequests (array $ requests, array $ options = [] )
53
55
{
56
+ $ options = $ this ->buildOptions ($ options );
57
+
54
58
$ results = Pool::batch (
55
59
$ this ->client ,
56
- $ requests
60
+ $ requests ,
61
+ $ options
57
62
);
58
63
59
64
$ exceptions = [];
@@ -101,4 +106,23 @@ private function createException(RequestException $exception)
101
106
102
107
return $ adapterException ;
103
108
}
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
+ }
104
128
}
You can’t perform that action at this time.
0 commit comments