Skip to content

Commit

Permalink
Move around the header addition ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperaj committed Jul 17, 2024
1 parent f2e2bdc commit 8dd5a11
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ public function __construct(readonly private SignatureV4 $signer, array $headers

public function sign(RequestInterface $request): RequestInterface
{
$request = $this->signer->signRequest($request, $this->credentials);

foreach ($this->headers as $header => $value) {
$request = $request->withHeader($header, $value);
}

$request = $this->signer->signRequest($request, $this->credentials);

// if the Authorization header has been supplied then it is with the understanding
// that it replaces anything generated by the AWS signing process.
if (array_key_exists('Authorization', $this->headers)) {
$request = $request->withHeader('Authorization', $this->headers['Authorization']);
}

return $request;
}
}

0 comments on commit 8dd5a11

Please sign in to comment.