Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Dancer CPAN distribution.

Report information
The Basics
Id: 57805
Status: resolved
Priority: 0/
Queue: Dancer

People
Owner: Nobody in particular
Requestors: richard_david_evans [...] yahoo.co.uk
Cc:
AdminCc:

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



Subject: Serializer issue: params hash not populated when the Content-Type is a supported media type with additional parameters
Date: Mon, 24 May 2010 21:23:38 +0100
To: bug-Dancer [...] rt.cpan.org
From: Richard Evans <richard_david_evans [...] yahoo.co.uk>
Hello Dancer-1.1803 I've just started using Dancer as a backend for Sproutcore, and am using Dancer's JSON serializer for automatic (de)serialization. In some cases the params hash is not populated on POSTs, despite firebug showing valid JSON requests. Looking at the requests being sent, depending on the context, either of the following Content-Types are set: * application/json * application/json; charset=UTF-8 The first case works correctly, it's when the "charset" parameter is present that the params hash is unpopulated. From a quick glance, I think the issue is in Dancer::Serializer::Abstract::support_content_type() sub support_content_type { my ($self, $ct) = @_; return $ct eq $self->content_type; } I'm guessing Dancer is comparing "application/json" to "application/json; charset=UTF-8" and therefore returning false, so it may need to split on the ";" or use a regexp. I think this should also be a case insensitive comparison, according to rfc2616. To reproduce: set serializer => 'JSON'; post '/test' => sub { return { test_value => params->{test_value} }; }; $ curl -H "Content-Type: application/json" -X POST http://localhost:3000/test -d '{"test_value":"set"}' {"test_value":"set"} $ curl -H "Content-Type: APPLICATION/JSON" -X POST http://localhost:3000/test -d '{"test_value":"set"}' {"test_value":null} $ curl -H "Content-Type: application/json; charset=UTF-8" -X POST http://localhost:3000/test -d '{"test_value":"set"}' {"test_value":null} Many thanks for all the work you're putting into Dancer, great stuff! Richard Evans -- richard_david_evans@yahoo.co.uk
Richard, thank you for opening this ticket. Since this seems to impact your usage of Dancer for Sproutcore, we'll make an effort to fix this soon enough. We will keep this ticket updated with the changes, and once it is fixed a new release will be shipped to CPAN. Thanks again, :) Sawyer.
Hi, FYI this bug is fixed in the master branch on GitHub, and should be released with the next CPAN version. http://github.com/sukria/Dancer/commit/7cc7a781b1bf1c72ff8ad73960cb8b1dc5ab6791 A test script has also been written to avoid future regressions: http://github.com/sukria/Dancer/commit/7849581e852fc245c978fbc1dd43995c030ed37f Thanks for the report.
Subject: Re: [rt.cpan.org #57805] Serializer issue: params hash not populated when the Content-Type is a supported media type with additional parameters
Date: Tue, 15 Jun 2010 00:46:21 +0100
To: bug-Dancer [...] rt.cpan.org
From: Richard Evans <richard_david_evans [...] yahoo.co.uk>
Looking good, thanks for the fix. Richard
closed in 1.1804