On Friday 18 December 2009 05:11:56 am Alex Povolotsky wrote: > Hello! > > I'm (still) working with weird client-weird server-weird DB system, and > I need some more help from community. > > Weird self-written client sends POST request without setting > Content-Type at all. > > Client will be fixed, but until then I have to force Catalyst to parse > that request as if it's type was application/x-www-form-urlencoded. > > How do I do that? > Here's a suggestion -- not sure if it's the best one, but it should work. In your app class (MyApp.pm or whatever) do:
before 'prepare_body' => sub { my $c = shift; if ($c->req->method eq 'POST' && !defined $c->req->content_type) { $c->req->content_type('application/x-www-form-urlencoded'); } }; The actual decision on how to parse the body is done by HTTP::Body, not by Catalyst, so it can't easily be overridden, but using this trick we hook into Catalyst after the headers are parsed but before HTTP::Body is invoked, and fool it into thinking that the Content-Type actually is what you want it to be. Andrew _______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/