Deal with nasty q headers (chansen)
Tomas Doran [Thu, 19 Nov 2009 10:06:28 +0000 (10:06 +0000)]
Changes
lib/Catalyst/Request/REST.pm

diff --git a/Changes b/Changes
index cc7148f..cb8a1f6 100644 (file)
--- 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
index 41d2a21..16c1e6a 100644 (file)
@@ -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 );
             }