12
12
namespace Http \Adapter ;
13
13
14
14
use GuzzleHttp \Client ;
15
+ use GuzzleHttp \ClientInterface ;
15
16
use GuzzleHttp \Exception \RequestException ;
16
17
use GuzzleHttp \Pool ;
17
18
use Http \Adapter \Common \Exception \HttpAdapterException ;
27
28
class Guzzle6HttpAdapter implements HttpAdapter
28
29
{
29
30
/**
30
- * @param Client $client
31
+ * @var ClientInterface
31
32
*/
32
- public function __construct (Client $ client = null )
33
+ private $ client ;
34
+
35
+ /**
36
+ * @param ClientInterface|null $client
37
+ */
38
+ public function __construct (ClientInterface $ client = null )
33
39
{
34
40
$ this ->client = $ client ?: new Client ();
35
41
}
@@ -43,8 +49,8 @@ public function sendRequest(RequestInterface $request, array $options = [])
43
49
44
50
try {
45
51
return $ this ->client ->send ($ request , $ options );
46
- } catch (RequestException $ exception ) {
47
- throw $ this ->createException ($ exception );
52
+ } catch (RequestException $ e ) {
53
+ throw $ this ->createException ($ e );
48
54
}
49
55
}
50
56
@@ -55,11 +61,7 @@ public function sendRequests(array $requests, array $options = [])
55
61
{
56
62
$ options = $ this ->buildOptions ($ options );
57
63
58
- $ results = Pool::batch (
59
- $ this ->client ,
60
- $ requests ,
61
- $ options
62
- );
64
+ $ results = Pool::batch ($ this ->client , $ requests , $ options );
63
65
64
66
$ exceptions = [];
65
67
$ responses = [];
@@ -88,7 +90,7 @@ public function getName()
88
90
}
89
91
90
92
/**
91
- * Convert Guzzle exception into HttpAdapter exception
93
+ * Converts a Guzzle exception into an HttpAdapter exception
92
94
*
93
95
* @param RequestException $exception
94
96
*
@@ -116,7 +118,10 @@ private function createException(RequestException $exception)
116
118
*/
117
119
private function buildOptions (array $ options )
118
120
{
119
- $ guzzleOptions = [];
121
+ $ guzzleOptions = [
122
+ 'http_errors ' => false ,
123
+ 'allow_redirects ' => false ,
124
+ ];
120
125
121
126
if (isset ($ options ['timeout ' ])) {
122
127
$ guzzleOptions ['connect_timeout ' ] = $ options ['timeout ' ];
0 commit comments