Skip to content

Commit

Permalink
avoid using array_merge_recursive in HTTP client for when array does…
Browse files Browse the repository at this point in the history
…nt make snese (#31858)
  • Loading branch information
themsaid authored Mar 9, 2020
1 parent cb095f3 commit ce4a05f
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/Illuminate/Http/Client/PendingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,7 @@ public function withHeaders(array $headers)
public function withBasicAuth(string $username, string $password)
{
return tap($this, function ($request) use ($username, $password) {
return $this->options = array_merge_recursive($this->options, [
'auth' => [$username, $password],
]);
return $this->options['auth'] = [$username, $password];
});
}

Expand All @@ -262,9 +260,7 @@ public function withBasicAuth(string $username, string $password)
public function withDigestAuth($username, $password)
{
return tap($this, function ($request) use ($username, $password) {
return $this->options = array_merge_recursive($this->options, [
'auth' => [$username, $password, 'digest'],
]);
return $this->options['auth'] = [$username, $password, 'digest'];
});
}

Expand All @@ -277,9 +273,9 @@ public function withDigestAuth($username, $password)
*/
public function withToken($token, $type = 'Bearer')
{
return $this->withHeaders([
'Authorization' => trim($type.' '.$token),
]);
return tap($this, function ($request) use ($token, $type) {
return $this->options['headers']['Authorization'] = trim($type.' '.$token);
});
}

/**
Expand All @@ -306,9 +302,7 @@ public function withCookies(array $cookies, string $domain)
public function withoutRedirecting()
{
return tap($this, function ($request) {
return $this->options = array_merge_recursive($this->options, [
'allow_redirects' => false,
]);
return $this->options['allow_redirects'] = false;
});
}

Expand All @@ -320,9 +314,7 @@ public function withoutRedirecting()
public function withoutVerifying()
{
return tap($this, function ($request) {
return $this->options = array_merge_recursive($this->options, [
'verify' => false,
]);
return $this->options['verify'] = false;
});
}

Expand Down

0 comments on commit ce4a05f

Please sign in to comment.