Description: Fix for Perl 5.42 / HTTP::Tiny v0.090
Origin: https://github.com/cv-library/WebService-S3-Tiny/pull/8
Bug: https://github.com/cv-library/WebService-S3-Tiny/pull/8
Author: José Joaquín Atria 
Reviewed-by: gregor herrmann <gregoa@debian.org>
Last-Update: 2025-08-22

From f6b0d551108313967a9646daa239ad056a2685d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Joaqu=C3=ADn=20Atria?=
 <j.atria@cv-library.co.uk>
Date: Thu, 17 Apr 2025 23:17:50 +0100
Subject: [PATCH 1/6] Make upstream test suite pass with HTTP::Tiny v0.090

HTTP::Tiny v0.090 shipped with a change that meant that calls
to 'www_form_urlencode', which we use to encode query parameters,
no longer sort on keys _and_ values, but only on keys [1]. While
this is arguably a sensible change, it means that the canonical
Amazon Signature Version 4 test suite we include as part of our own,
which relies on specific signatures being generated for specific
requests, no longer passes.

This change makes the test suite use an array reference instead of
a hash reference for the last parameter to 'request', which is then
passed as-is to HTTP::Tiny's 'www_form_urlencode', and allows us to
control the order of the parts that make up the encoded string.

We do not document supporting an array reference to be used in this
case, and this change does not modify this.

Fixes #7.

[1]: https://github.com/Perl-Toolchain-Gang/HTTP-Tiny/commit/9fcfe7cf19ba622fdfdfe0deb9ca99832164f50f
---
 t/aws.t | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/t/aws.t b/t/aws.t
index b269dc1..db1fcde 100644
--- a/t/aws.t
+++ b/t/aws.t
@@ -33,13 +33,8 @@ for (<{get,post}-*>) {
 
     ( $path, my $query ) = split /\?/, $path;
 
-    my %query;
-
-    for ( split /&/, $query // '' ) {
-        my ( $k, $v ) = split /=/;
-
-        push @{ $query{$k} }, $v;
-    }
+    my @query = split /&/, ( $query // '' );
+    @query = map { split /=/, $_, 2 } sort @query;
 
     ( $headers, my $content ) = split /\n\n/, $headers;
 
@@ -55,7 +50,7 @@ for (<{get,post}-*>) {
         undef,
         $req->content,
         \%headers,
-        \%query,
+        \@query,
     ) => slurp "$_/$_.authz", $_;
 }
 
