Dave Rolsky wrote:
On Sun, 20 Jan 2008, Thomas L. Shinnick wrote:

They specifically allow that when PUT is not available or impracticable (clients, firewalls, and proxies can get in the way), you could 'overload' POST by, for example, adding a query parameter "_method=PUT" to pass-thru the real request method. The idea is that the handler would pick off this parameter and dispatch as though the HTTP method had really been PUT. But you try to use this request like you would a 'real' PUT, in what the data contains and how it is used.

But this is a question I have, whether the REST dispatching modules have an capability like this, interpreting overloaded POSTs?

I added this to a custom Catalyst::Request subclass I use for my app. It looks like this:

 sub method
 {
     my $self = shift;

     return $self->NEXT::method(@_)
         if @_;

     return $self->{__method} if $self->{__method};

     my $method = $self->NEXT::method();

     return $method unless $method && uc $method eq 'POST';

     my $tunneled = $self->param('x-tunneled-method');

     return $self->{__method} = $tunneled ? $tunneled : $method;
 }


-dave

Here's my hack against my REST controller subclass of C::Controller::REST:

    if ($c->request->method eq 'POST' && $c->request->param('_method')) {
        $c->request->method(uc $c->request->param('_method'));
    };


Since the REST package already has a Request subclass, I didn't really want to make yet another one...esp if the SOAP stuff also gets loaded.

-=Chris

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
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/

Reply via email to