Skip Menu |

This queue is for tickets about the Catalyst-Action-REST CPAN distribution.

Report information
The Basics
Id: 106403
Status: open
Priority: 0/
Queue: Catalyst-Action-REST

People
Owner: Nobody in particular
Requestors: perl [...] evancarroll.com
Cc:
AdminCc:

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



Subject: Catalyst::Controller::Rest and default types.
Getting [info] Could not find a serializer for an empty content-type When I submit a request with, Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Encoding:gzip, deflate, sdch Accept-Language:en,en-US;q=0.8 Cache-Control:max-age=0 Connection:keep-alive Host:sentrydev User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/43.0.2357.130 Chrome/43.0.2357.130 Safari/537.36 First, I'd expect it to use "Accept", but even if not, the docs for Catalyst::Controller::Rest says, By default, Catalyst::Controller::REST will return a 415 Unsupported Media Type response if an attempt to use an unsupported content-type is made. You can ensure that something is always returned by setting the default config option: __PACKAGE__->config(default => 'text/x-yaml'); However, adding that line to my PACKAGE is no dice. -- Evan Carroll System Lord of the Internets http://www.evancarroll.com
Ok so there are a bunch of issues here.. First, the content-type isn't empty. I can get that same error if I explicitly have a content-type in the URI. ?content-type=text/x-yaml Second.. the problem here is that the __PACKAGE__->config(map=>{}) is improperly configured. Taking a look at this the docs are wrong.. You'll see a list of defaults under "Configures the Serialization Actions" at this page Show quoted text
However, the source clearly only lists three of them, and most importantly does not have a map for text/x-yaml. The source currently only supports text/xml, application/json and text/x-json Show quoted text
Per the docs, adding "__PACKAGE__->config(default => 'text/yaml');" to change the default to text/yaml doesn't work because text/yaml isn't one of the three options in __PACKAGE__->config(map=>{}) (check link above on L289 of Catalyst/Controller/REST.pm). So we have two options.. * Either make the ->config(map=>{}) in the source match the docs. This means we support more stuff and have a more sane default (good idea.) * Make note of what we don't support and support change it in the docs. * If we don't support the text/, don't suggest making it the default. (Seriously, what the fuck.) As it sits, __PACKAGE__->config(default => 'text/x-yaml'); Is a recipe to break shit. You'd have to change that to one of the three options mentioned above.. __PACKAGE__->config(default => 'text/x-json'); I can fix all this stuff with a patch if you want.. But, if you let it sour for five years, as some of the other ones on here have, I'll hunt you down and kill you. =/ w/ love. -- Evan Carroll System Lord of the Internets http://www.evancarroll.com
This is a doc bug, and a patch to fix it would be great. YAML support got disabled by default because of the whole "hey, YAML can include objects and coderefs and stuff and WOW but that's hilariously awful for security so you have to turn it on yourself" problem. Apparently whoever did that completely missed that bit of the documentation, sorry.
What about __PACKAGE__->config('default' => ''). That's also not working. \ REQUEST HEADER. Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Encoding:gzip, deflate, sdch Accept-Language:en,en-US;q=0.8 Cache-Control:max-age=0 Connection:keep-alive Cookie:SentryDevId=6f23a55289681763544db8870528a073 Host:sentrydev User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/43.0.2357.130 Chrome/43.0.2357.130 Safari/537.36 URL: http://sentrydev/rest/client/1/holiday It's returning content-type=text/x-json, should be returning content-type=application/json... (both in map) -- Evan Carroll System Lord of the Internets http://www.evancarroll.com
ERg.. Show quoted text
> It's returning content-type=text/x-json, should be returning content- > type=application/json... (both in map)
Meant to say.. It's returning content-type=text/x-yaml, should be returning content-type=application/json... (both in map) -- Evan Carroll System Lord of the Internets http://www.evancarroll.com
Nevermind on the default problem.. I see what's happening. I'm setting __PACKAGE__->config('default' => 'application/json').. But in my map I have __PACKAGE__->config('map' =>{'text/html' => 'YAML::HTML' }) and in the ACCEPT header, I have Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 So it's reading the Accept header, sees text/html and uses the map to serialize with YAML::HTML.. It's not really YAML, it's YAML::HTML and I was just looking at it in the browser. All fixed.. YAML::HTML is such a stupid idea.. Just what we need something that marks up plain text as HTML so a browser that can render plain text just fine, can spend twice as much work rendering it html in the same fashion.. -- Evan Carroll System Lord of the Internets http://www.evancarroll.com