From: Tomas Doran Date: Thu, 19 Nov 2009 10:06:28 +0000 (+0000) Subject: Deal with nasty q headers (chansen) X-Git-Tag: 0.79~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-REST.git;a=commitdiff_plain;h=5bbe8fb2380d1d5bc86eb0e595f30c76aa29d6b2 Deal with nasty q headers (chansen) --- diff --git a/Changes b/Changes index cc7148f..cb8a1f6 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Mon 28 Sep 15:01:03 BST 2009 - Release 0.78 + Cope with invalid (missing required q parameter) header like: + application/json; charset="utf-8" + Require Moose for the tests (RT#50066). Thu 27 Aug 02:21:09 BST 2009 - Release 0.77 diff --git a/lib/Catalyst/Request/REST.pm b/lib/Catalyst/Request/REST.pm index 41d2a21..16c1e6a 100644 --- a/lib/Catalyst/Request/REST.pm +++ b/lib/Catalyst/Request/REST.pm @@ -128,6 +128,13 @@ sub accepted_content_types { my ( $type, $qvalue ) = @{$pair}[ 0, 3 ]; next if $types{$type}; + # cope with invalid (missing required q parameter) header like: + # application/json; charset="utf-8" + # http://tools.ietf.org/html/rfc2616#section-14.1 + unless ( defined $pair->[2] && lc $pair->[2] eq 'q' ) { + $qvalue = undef; + } + unless ( defined $qvalue ) { $qvalue = 1 - ( ++$counter / 1000 ); }