diff --git a/README.md b/README.md index 27fef07..3e56bb6 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ $httpClient = new HttpClient([ ], 'driver' => 'auto', // (Auto|Guzzle5|Guzzle6|Rmccue) 'timeout' => 10, // Wait in seconds - 'verify' => false, // check cert for SSL + 'verify' => false, // Check cert for SSL 'exceptions' => false, // Show exceptions for statuses 4xx and 5xx 'allow_redirects' => true, // Show real 3xx-header or result? 'max_redirects' => 10, // How much to reirect? @@ -76,8 +76,8 @@ $value = $json->find('key.nested', 'default', 'trim'); ```php $httpClient = new HttpClient(); -$results = $httpClient->multiRequest([ - 'request_0' => ['http://mockbin.org/request'], +$results = $httpClient->multiRequest(array( + 'request_0' => 'http://mockbin.org/request', 'request_1' => ['http://mockbin.org/request', [ 'args' => ['key' => 'value'] ]], diff --git a/src/Driver/Guzzle5.php b/src/Driver/Guzzle5.php index bbd7cb3..7ece1eb 100644 --- a/src/Driver/Guzzle5.php +++ b/src/Driver/Guzzle5.php @@ -53,6 +53,11 @@ public function multiRequest(array $urls) $requests = array(); foreach ($urls as $urlName => $urlData) { + + if (is_string($urlData)) { + $urlData = array($urlData, array()); + } + $urlOptions = new Options($urlData[1]); $method = $urlOptions->get('method', 'GET', 'up'); diff --git a/src/Driver/Guzzle6.php b/src/Driver/Guzzle6.php index 76ec2cb..4b0511f 100644 --- a/src/Driver/Guzzle6.php +++ b/src/Driver/Guzzle6.php @@ -51,6 +51,11 @@ public function multiRequest(array $urls) $promises = array(); foreach ($urls as $urlName => $urlData) { + + if (is_string($urlData)) { + $urlData = array($urlData, array()); + } + $urlOptions = new Options($urlData[1]); $method = $urlOptions->get('method', 'GET', 'up'); diff --git a/src/Driver/Rmccue.php b/src/Driver/Rmccue.php index ed6a5fd..3b2ef2e 100644 --- a/src/Driver/Rmccue.php +++ b/src/Driver/Rmccue.php @@ -60,6 +60,11 @@ public function multiRequest(array $urls) { $requests = array(); foreach ($urls as $urlName => $urlData) { + + if (is_string($urlData)) { + $urlData = array($urlData, array()); + } + $urlOptions = new Options($urlData[1]); $method = $urlOptions->get('method', 'GET', 'up'); diff --git a/tests/DriverAutoTest.php b/tests/DriverAutoTest.php index 4886a31..0f04503 100644 --- a/tests/DriverAutoTest.php +++ b/tests/DriverAutoTest.php @@ -26,6 +26,8 @@ protected function setUp() { parent::setUp(); + sleep(1); // for mockservers + if ($this->_isPHP53()) { $this->_methods = array('GET', 'POST', 'PATCH', 'PUT'); // TODO add 'DELETE' } diff --git a/tests/DriverTest.php b/tests/DriverTest.php index 3154aba..74919ba 100644 --- a/tests/DriverTest.php +++ b/tests/DriverTest.php @@ -315,6 +315,7 @@ public function testSSL() public function testMultiRequest() { $results = $this->_getClient()->multiRequest(array( + 'request_0' => 'http://mockbin.org/request?qwerty=123456', 'request_1' => array('http://mockbin.org/request', array( 'args' => array('key' => 'value') )), @@ -324,6 +325,11 @@ public function testMultiRequest() )) )); + /** @var Response $body1 */ + $body1 = $results['request_0']->getJSON(); + isSame('GET', $body1->find('method')); + isSame('123456', $body1->find('queryString.qwerty')); + /** @var Response $body1 */ $body1 = $results['request_1']->getJSON(); isSame('GET', $body1->find('method'));