Skip to content

Commit

Permalink
support closure based global options
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 8, 2024
1 parent 69e4085 commit b1f3f0d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Illuminate/Http/Client/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Factory
/**
* The options to apply to every request.
*
* @var array
* @var \Closure|array
*/
protected $globalOptions = [];

Expand Down Expand Up @@ -133,7 +133,7 @@ public function globalResponseMiddleware($middleware)
/**
* Set the options to apply to every request.
*
* @param array $options
* @param \Closure|array $options
* @return $this
*/
public function globalOptions($options)
Expand Down Expand Up @@ -420,7 +420,7 @@ public function recorded($callback = null)
*/
protected function newPendingRequest()
{
return (new PendingRequest($this, $this->globalMiddleware))->withOptions($this->globalOptions);
return (new PendingRequest($this, $this->globalMiddleware))->withOptions(value($this->globalOptions));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Http/HttpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3011,7 +3011,7 @@ public function testItCanHaveGlobalDefaultValues()
$this->assertFalse($allowRedirects);
$this->assertSame(['true'], $headers['X-Foo']);

$factory->globalOptions([
$factory->globalOptions(fn () => [
'timeout' => 10,
'headers' => [
'X-Foo' => 'false',
Expand Down

0 comments on commit b1f3f0d

Please sign in to comment.