Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change guzzle client creation (linked to PR in laravel-plugin) #403

Open
wants to merge 1 commit into
base: v3
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions src/Http/Senders/GuzzleSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,37 @@
*/
protected function createGuzzleClient(): GuzzleClient
{
// We'll use HandlerStack::create as it will create a default
// handler stack with the default Guzzle middleware like
// http_errors, cookies etc.

$this->handlerStack = HandlerStack::create();

// Now we'll return new Guzzle client with some default request
// options configured. We'll also define the handler stack we
// created above. Since it's a property, developers may
// customise or add middleware to the handler stack.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments should probably be updated a little bit. "Now" doesn't make sense anymore and the handler stack is not being created above anymore.


return new GuzzleClient([
return new GuzzleClient($this->getGuzzleClientConfig());
}

/**
* Get Guzzle client config
*/
protected function getGuzzleClientConfig() : array

Check failure on line 80 in src/Http/Senders/GuzzleSender.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Saloon\Http\Senders\GuzzleSender::getGuzzleClientConfig() return type has no value type specified in iterable type array.
{
return [
RequestOptions::CRYPTO_METHOD => Config::$defaultTlsMethod,
RequestOptions::CONNECT_TIMEOUT => Config::$defaultConnectionTimeout,
RequestOptions::TIMEOUT => Config::$defaultRequestTimeout,
RequestOptions::HTTP_ERRORS => true,
'handler' => $this->handlerStack,
]);
'handler' => $this->createGuzzleHandlerStack(),
];
}

/**
* Create a new Guzzle handler stack
*/
protected function createGuzzleHandlerStack() : HandlerStack
{
// We'll use HandlerStack::create as it will create a default
// handler stack with the default Guzzle middleware like
// http_errors, cookies etc.
return $this->handlerStack = HandlerStack::create();
}

/**
Expand Down
Loading