Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #19 from php-http/fix-guzzle-setup
Browse files Browse the repository at this point in the history
reduced default guzzle set up
  • Loading branch information
joelwurtz committed Dec 17, 2015
2 parents b9d4024 + 5e4fdd8 commit 9f58018
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,10 @@
# Change Log

### Unreleased

### Changed

- Guzzle setup conforms to HTTPlug requirement now: Minimal functionality in client

## 0.2.0 - 2015-12-15

Expand Down
9 changes: 8 additions & 1 deletion src/Guzzle6HttpAdapter.php
Expand Up @@ -4,6 +4,8 @@

use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use Http\Client\HttpAsyncClient;
use Http\Client\HttpClient;
use Http\Client\Tools\HttpClientEmulator;
Expand All @@ -28,7 +30,12 @@ class Guzzle6HttpAdapter implements HttpClient, HttpAsyncClient
*/
public function __construct(ClientInterface $client = null)
{
$this->client = $client ?: new Client();
if (!$client) {
$handlerStack = new HandlerStack();
$handlerStack->push(Middleware::prepareBody(), 'prepare_body');
$client = new Client(['handler' => $handlerStack]);
}
$this->client = $client;
}

/**
Expand Down

0 comments on commit 9f58018

Please sign in to comment.