@@ -54,9 +54,13 @@ public function exec(Request $request, array $params): Response
54
54
{
55
55
$ connection = $ this ->getConnection ();
56
56
57
- $ client = $ this ->_getGuzzleClient ($ this -> _getBaseUrl ( $ connection), $ connection ->isPersistent (), $ request );
57
+ $ client = $ this ->_getGuzzleClient ($ connection ->isPersistent ());
58
58
59
59
$ options = [
60
+ 'base_uri ' => $ this ->_getBaseUrl ($ connection ),
61
+ 'headers ' => [
62
+ 'Content-Type ' => $ request ->getContentType (),
63
+ ],
60
64
'exceptions ' => false , // 4xx and 5xx is expected and NOT an exceptions in this context
61
65
];
62
66
if ($ connection ->getTimeout ()) {
@@ -150,21 +154,14 @@ protected function _createPsr7Request(Request $request, Connection $connection)
150
154
/**
151
155
* Return Guzzle resource.
152
156
*
153
- * @param string $baseUrl
154
- * @param bool $persistent False if not persistent connection
155
- * @param Request $request Elastica Request Object
157
+ * @param bool $persistent False if not persistent connection
156
158
*
157
159
* @return Client
158
160
*/
159
- protected function _getGuzzleClient (string $ baseUrl , bool $ persistent = true , Request $ request ): Client
161
+ protected function _getGuzzleClient (bool $ persistent = true ): Client
160
162
{
161
163
if (!$ persistent || !self ::$ _guzzleClientConnection ) {
162
- self ::$ _guzzleClientConnection = new Client ([
163
- 'base_uri ' => $ baseUrl ,
164
- 'headers ' => [
165
- 'Content-Type ' => $ request ->getContentType (),
166
- ],
167
- ]);
164
+ self ::$ _guzzleClientConnection = new Client ();
168
165
}
169
166
170
167
return self ::$ _guzzleClientConnection ;
0 commit comments