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

Commit 9f58018

Browse files
committed
Merge pull request #19 from php-http/fix-guzzle-setup
reduced default guzzle set up
2 parents b9d4024 + 5e4fdd8 commit 9f58018

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
### Unreleased
4+
5+
### Changed
6+
7+
- Guzzle setup conforms to HTTPlug requirement now: Minimal functionality in client
38

49
## 0.2.0 - 2015-12-15
510

src/Guzzle6HttpAdapter.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use GuzzleHttp\Client;
66
use GuzzleHttp\ClientInterface;
7+
use GuzzleHttp\HandlerStack;
8+
use GuzzleHttp\Middleware;
79
use Http\Client\HttpAsyncClient;
810
use Http\Client\HttpClient;
911
use Http\Client\Tools\HttpClientEmulator;
@@ -28,7 +30,12 @@ class Guzzle6HttpAdapter implements HttpClient, HttpAsyncClient
2830
*/
2931
public function __construct(ClientInterface $client = null)
3032
{
31-
$this->client = $client ?: new Client();
33+
if (!$client) {
34+
$handlerStack = new HandlerStack();
35+
$handlerStack->push(Middleware::prepareBody(), 'prepare_body');
36+
$client = new Client(['handler' => $handlerStack]);
37+
}
38+
$this->client = $client;
3239
}
3340

3441
/**

0 commit comments

Comments
 (0)