Skip to content

Commit 7b50d49

Browse files
committed
Reduce the number of call to API if not needed in case of the XAuth Token Header is not present
1 parent 0b41280 commit 7b50d49

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Client/AuthenticatedHttpClient.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ public function __construct(
4545
public function sendRequest($httpMethod, $uri, array $headers = [], $body = null)
4646
{
4747
try {
48+
$xauthtokenDetected = false;
4849
foreach ((array) $this->authentication->getXauthtokenHeader() as $name => $value) {
4950
$headers[$name] = $value;
51+
$xauthtokenDetected = true;
5052
}
5153

52-
return $this->basicHttpClient->sendRequest($httpMethod, $uri, $headers, $body);
54+
if ($xauthtokenDetected) {
55+
return $this->basicHttpClient->sendRequest($httpMethod, $uri, $headers, $body);
56+
}
5357
} catch (UnauthorizedHttpException $e) {
5458
// Do nothing and process to standard authentication
5559
}

0 commit comments

Comments
 (0)