From 7efe3cb56fcaef84ca43f57f78bd9cd3053f8cab Mon Sep 17 00:00:00 2001 From: Fred Date: Fri, 22 Oct 2021 08:52:42 +0800 Subject: [PATCH] add digest generation --- src/HttpSignatures/GuzzleHttpSignatures.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/HttpSignatures/GuzzleHttpSignatures.php b/src/HttpSignatures/GuzzleHttpSignatures.php index 8b774f7..0d060ff 100644 --- a/src/HttpSignatures/GuzzleHttpSignatures.php +++ b/src/HttpSignatures/GuzzleHttpSignatures.php @@ -25,13 +25,14 @@ class GuzzleHttpSignatures */ public static function middlewareFromContext(Context $context) { - return function (callable $handler) use ($context) - { + return function (callable $handler) use ($context) { return function ( Request $request, array $options - ) use ($handler, $context) - { + ) use ($handler, $context) { + + $contentsRequest = (string) $request->getBody(); + $request = $request->withAddedHeader("digest", base64_encode(hash('sha512', $contentsRequest, true))); $request = $context->signer()->sign($request); return $handler($request, $options); };