8p / EightPointsGuzzleBundle

⛽️ Integrates Guzzle 6.x, a PHP HTTP Client, into Symfony
MIT License
440 stars 71 forks source link

Unable not resolve host results in FatalThrowableError #116

Closed bouke-nederstigt closed 7 years ago

bouke-nederstigt commented 7 years ago

When the client is unable to resolve the host for a request (cURL error 6) it seems guzzle does not return a ResponseInterface. This in turn causes guzzle bundle to throw the following fatal error.

Type error: Argument 1 passed to EightPoints\Bundle\GuzzleBundle\Events\PostTransactionEvent::__construct() must be an instance of Psr\Http\Message\ResponseInterface, null given, called in /var/www/application/vendor/eightpoints/guzzle-bundle/EightPoints/Bundle/GuzzleBundle/Middleware/EventDispatchMiddleware.php on line 70

PHP 7.1.7-1+ubuntu14.04.1+deb.sury.org+1 Tested with guzzle bundle 5.4.0 and 6.0.0 Symfony v3.2.13

Request is initiated with the following code:

$request = new Request("POST", "http://test.webhook.nl/webhook", $this->client->getConfig('headers'), json_encode($body));
$response = $this->client->send($request);

Client is setup using following config

guzzle:
    logging: true # Always log all requests
    clients:
        common_client:
            base_url: ""
            options:
                headers:
                    Content-Type: "application/json"
                    Accept: "application/json"
TheLevti commented 7 years ago

@bouke-nederstigt I noticed that when I fixed another bug. My latest PR #115 fixed this issue (see issue #114). Try to use the master branch. The PostTransactionEvent::__construct() there is supporting null values.

bouke-nederstigt commented 7 years ago

That solves it. Thanks a lot!

florianpreusner commented 7 years ago

Just released v6.0.1 https://github.com/8p/GuzzleBundle/releases/tag/v6.0.1