7777class PhpBrowser extends InnerBrowser implements Remote, MultiSession, RequiresPackage
7878{
7979
80- private $ isGuzzlePsr7 ;
8180 protected $ requiredFields = ['url ' ];
8281
8382 protected $ config = [
@@ -122,28 +121,18 @@ class PhpBrowser extends InnerBrowser implements Remote, MultiSession, RequiresP
122121
123122 public function _requires ()
124123 {
125- return ['GuzzleHttp\Client ' => '"guzzlehttp/guzzle": ">=4.1.4 <7.0" ' ];
124+ return ['GuzzleHttp\Client ' => '"guzzlehttp/guzzle": ">=6.3.0 <7.0" ' ];
126125 }
127126
128127 public function _initialize ()
129128 {
130129 $ this ->_initializeSession ();
131130 }
132131
133- protected function guessGuzzleConnector ()
134- {
135- if (class_exists ('GuzzleHttp\Url ' )) {
136- $ this ->isGuzzlePsr7 = false ;
137- return new \Codeception \Lib \Connector \Guzzle ();
138- }
139- $ this ->isGuzzlePsr7 = true ;
140- return new \Codeception \Lib \Connector \Guzzle6 ();
141- }
142-
143132 public function _before (TestInterface $ test )
144133 {
145134 if (!$ this ->client ) {
146- $ this ->client = $ this -> guessGuzzleConnector ();
135+ $ this ->client = new Guzzle6 ();
147136 }
148137 $ this ->_prepareSession ();
149138 }
@@ -231,7 +220,7 @@ public function _getResponseCode()
231220 public function _initializeSession ()
232221 {
233222 // independent sessions need independent cookies
234- $ this ->client = $ this -> guessGuzzleConnector ();
223+ $ this ->client = new Guzzle6 ();
235224 $ this ->_prepareSession ();
236225 }
237226
@@ -249,22 +238,16 @@ public function _prepareSession()
249238 $ this ->headers = $ this ->config ['headers ' ];
250239 $ this ->setCookiesFromOptions ();
251240
252- if ($ this ->isGuzzlePsr7 ) {
253- $ defaults ['base_uri ' ] = $ this ->config ['url ' ];
254- $ defaults ['curl ' ] = $ curlOptions ;
255- $ handler = Guzzle6::createHandler ($ this ->config ['handler ' ]);
256- if ($ handler && is_array ($ this ->config ['middleware ' ])) {
257- foreach ($ this ->config ['middleware ' ] as $ middleware ) {
258- $ handler ->push ($ middleware );
259- }
241+ $ defaults ['base_uri ' ] = $ this ->config ['url ' ];
242+ $ defaults ['curl ' ] = $ curlOptions ;
243+ $ handler = Guzzle6::createHandler ($ this ->config ['handler ' ]);
244+ if ($ handler && is_array ($ this ->config ['middleware ' ])) {
245+ foreach ($ this ->config ['middleware ' ] as $ middleware ) {
246+ $ handler ->push ($ middleware );
260247 }
261- $ defaults ['handler ' ] = $ handler ;
262- $ this ->guzzle = new GuzzleClient ($ defaults );
263- } else {
264- $ defaults ['config ' ]['curl ' ] = $ curlOptions ;
265- $ this ->guzzle = new GuzzleClient (['base_url ' => $ this ->config ['url ' ], 'defaults ' => $ defaults ]);
266- $ this ->client ->setBaseUri ($ this ->config ['url ' ]);
267248 }
249+ $ defaults ['handler ' ] = $ handler ;
250+ $ this ->guzzle = new GuzzleClient ($ defaults );
268251
269252 $ this ->client ->setRefreshMaxInterval ($ this ->config ['refresh_max_interval ' ]);
270253 $ this ->client ->setClient ($ this ->guzzle );
0 commit comments