Skip to content

Commit

Permalink
Utilizing GuzzleHttp Psr7 request and stream classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone committed Apr 10, 2017
1 parent d271725 commit 0f20497
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 639 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ php:
- 7.0
- 7.1

before_script:
- composer self-update 1.2.1
install:
- composer install --no-interaction -v

script:
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": ">=5.6.0",
"psr/log": "1.0.*",
"psr/http-message": "1.0.*",
"guzzlehttp/psr7": "1.4.*",
"php-http/client-implementation": "@stable"
},
"autoload": {
Expand All @@ -40,7 +40,6 @@
}
},
"suggest": {
"php-http/guzzle5-adapter": "To enable use of Guzzle 5 http client (http://docs.php-http.org/en/latest/clients/guzzle5-adapter.html)",
"php-http/guzzle6-adapter": "To enable use of Guzzle 6 http client (http://docs.php-http.org/en/latest/clients/guzzle6-adapter.html)",
"php-http/react-adapter": "To enable React http client (http://docs.php-http.org/en/latest/clients/react-adapter.html)",
"php-http/buzz-adapter": "To enable use of Buzz http client (http://docs.php-http.org/en/latest/clients/buzz-adapter.html)",
Expand Down
7 changes: 3 additions & 4 deletions src/AbstractClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
limitations under the License.
*/

use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;

Expand Down Expand Up @@ -87,14 +86,14 @@ protected function requireOK(array $r)
}

/**
* @param RequestInterface $r
* @param Request $r
* @return array(
* @type int duration in microseconds
* @type \Psr\Http\Message\ResponseInterface|null http response
* @type \DCarbone\PHPConsulAPI\Error|null any seen errors
* )
*/
protected function doRequest(RequestInterface $r)
protected function doRequest(Request $r)
{
$rt = microtime(true);
$response = null;
Expand All @@ -103,7 +102,7 @@ protected function doRequest(RequestInterface $r)
{
// If we actually have a client defined...
if (isset($this->c->HttpClient))
$response = $this->c->HttpClient->sendRequest($r);
$response = $this->c->HttpClient->sendRequest($r->toPsrRequest());
// Otherwise, throw error to be caught below
else
throw new \RuntimeException('Unable to execute query as no HttpClient has been defined.');
Expand Down
Loading

0 comments on commit 0f20497

Please sign in to comment.