Subject: | [PATCH] Use content sha256 from request if available |
I have a patch for: https://rt.cpan.org/Public/Bug/Display.html?id=81219
But this patch needs to go in first. This patch reduces memory usage in cases where content-sha256 has already been calculated by the client code.
Subject: | 0001-Use-content-sha256-from-request-if-available.patch |
From 1745ac2603a144b2bfaea1603f1ca3c13c2ceee5 Mon Sep 17 00:00:00 2001
From: Pyry Hakulinen <pyry@automattic.com>
Date: Sun, 9 Dec 2012 22:20:08 +0200
Subject: [PATCH] Use content sha256 from request if available
Post body might be huge and some client libraries already calculate
SHA256, we can just re-use it here.
---
Net-Amazon-Signature-V4-0.13/lib/Net/Amazon/Signature/V4.pm | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Net-Amazon-Signature-V4-0.13/lib/Net/Amazon/Signature/V4.pm b/Net-Amazon-Signature-V4-0.13/lib/Net/Amazon/Signature/V4.pm
index 3694b6b..e9d35a1 100644
--- a/Net-Amazon-Signature-V4-0.13/lib/Net/Amazon/Signature/V4.pm
+++ b/Net-Amazon-Signature-V4-0.13/lib/Net/Amazon/Signature/V4.pm
@@ -99,7 +99,7 @@ sub _canonical_request {
}
@sorted_headers;
my $creq_signed_headers = join ';', map {lc} @sorted_headers;
- my $creq_payload_hash = sha256_hex( $req->content );
+ my $creq_payload_hash = $req->header('x-amz-content-sha256') ? $req->header('x-amz-content-sha256') : sha256_hex( $req->content );
my $creq = join "\n",
$creq_method, $creq_canonical_uri, $creq_canonical_query_string,
--
1.7.10.4