Skip Menu |

This queue is for tickets about the Amazon-S3 CPAN distribution.

Report information
The Basics
Id: 76602
Status: open
Priority: 0/
Queue: Amazon-S3

People
Owner: Nobody in particular
Requestors: chadd [...] fidelissys.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: file_exists: Odd number of elements in anonymous hash
I have a file uploaded with content_type => 'text/plain; charset=UTF-8'; when I check head_key for the file it triggers the above-mentioned warning and returns a hashref that looks like: # result of `say Dumper($bucket->head_key('test/upload-test.txt'));` Odd number of elements in anonymous hash at /usr/local/share/perl5/Amazon/S3/Bucket.pm line 90. $VAR1 = { '' => undef, 'content_length' => '758', 'content_type' => 'text/plain', 'charset=UTF-8' => 'etag', '335b8b...' => 'value' }; The text/plain and the charset got separated from each other, thus keys and values are swapped after that point, and the final value becomes the odd key that triggered the warning. In the S3 console, the complete "text/plain; charset=UTF-8" string is displayed as the value for "Content-Type". Observed with Amazon::S3 0.45 on perl 5.10.1 / centos 6.2.
Subject: [rt.cpan.org #76602]
Date: Wed, 19 Mar 2014 15:43:53 +0000
To: bug-Amazon-S3 [...] rt.cpan.org
From: Tom Hey <tom.hey [...] geniusdigital.tv>
I've just hit the bug reported in https://rt.cpan.org/Public/Bug/Display.html?id=76602 (version 0.45) As outlined in the bug report the problem occurs when retrieving an HTTP header that contains multiple content type. This results in the call "$response->content_type" (Bucket.pm: 92) returning something that messes up the "$return" hashref, my Perl is a little shaky here - something to do with the list/ scalar context and wantarray test HTTP::Headers.pm: sub content_type. I'm sure there are better ways of achieving this, but find below a patch that handles the content_type array edge case, by testing if there are multiple content types in which case these are stored as an arrayref. Regards, Tom Hey --- Bucket.pm.20140319 2014-03-19 14:25:35.408009075 +0000 +++ Bucket.pm 2014-03-19 15:10:21.836008920 +0000 @@ -88,7 +88,15 @@ } + my @content_type_a = $response->content_type; + my $content_type; + if ( scalar @content_type_a < 2 ) { + $content_type = $response->content_type; + } else { + $content_type = \@content_type_a; + } + my $return = { content_length => $response->content_length || 0, - content_type => $response->content_type, + content_type => $content_type, etag => $etag, value => $response->content,