Skip Menu |

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

Report information
The Basics
Id: 48306
Status: resolved
Priority: 0/
Queue: Catalyst-Request-REST-ForBrowsers

People
Owner: Nobody in particular
Requestors: cub.uanic [...] gmail.com
Cc:
AdminCc:

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



Subject: Adding synonym for 'x-tunneled-method'
Hi, Looking at Google API docs (http://code.google.com/intl/en/apis/gdata/docs/2.0/basics.html), I see that Google use "X-HTTP-Method-Override" header to tunnel http method, instead of "x-tunneled-method" param. I think will be great to support both possibilites in Catalyst::Request::REST::ForBrowsers. Patch is attached.
Subject: Catalyst-Request-REST-ForBrowsers-0.02.patch
diff -ur Catalyst-Request-REST-ForBrowsers-0.02.orig/lib/Catalyst/Request/REST/ForBrowsers.pm Catalyst-Request-REST-ForBrowsers-0.02/lib/Catalyst/Request/REST/ForBrowsers.pm --- Catalyst-Request-REST-ForBrowsers-0.02.orig/lib/Catalyst/Request/REST/ForBrowsers.pm 2009-04-20 23:33:28.000000000 +0300 +++ Catalyst-Request-REST-ForBrowsers-0.02/lib/Catalyst/Request/REST/ForBrowsers.pm 2009-07-29 21:14:27.000000000 +0300 @@ -25,7 +25,9 @@ return $method unless $method && uc $method eq 'POST'; - my $tunneled = $self->param('x-tunneled-method'); + my $tunneled = $self->param('x-tunneled-method') + || $self->param('x-http-method-override') + || $self->header('x-http-method-override'); return $self->{__method} = $tunneled ? uc $tunneled : $method; } @@ -114,6 +116,9 @@ which can override the request method for a POST. This I<only> works for a POST, not a GET. +You can also use "x-http-method-override" parameter or header +for the same purposes as "x-tunneled-method". + =head2 $request->looks_like_browser() This method provides a heuristic to say whether or not the request diff -ur Catalyst-Request-REST-ForBrowsers-0.02.orig/t/basic.t Catalyst-Request-REST-ForBrowsers-0.02/t/basic.t --- Catalyst-Request-REST-ForBrowsers-0.02.orig/t/basic.t 2009-04-20 23:33:28.000000000 +0300 +++ Catalyst-Request-REST-ForBrowsers-0.02/t/basic.t 2009-07-29 21:20:55.000000000 +0300 @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 17; +use Test::More tests => 21; use HTTP::Headers; use Catalyst::Request::REST::ForBrowsers; @@ -29,7 +29,33 @@ $req->parameters( { 'x-tunneled-method' => $method } ); is( $req->method(), $method, - "$method - tunneled" ); + "$method - tunneled with x-tunneled-method param" ); + } +} + +{ + for my $method ( qw( PUT DELETE ) ) + { + my $req = Catalyst::Request::REST::ForBrowsers->new(); + $req->method('POST'); + $req->{_context} = 'MockContext'; + $req->parameters( { 'x-http-method-override' => $method } ); + + is( $req->method(), $method, + "$method - tunneled with x-http-method-override param" ); + } +} + +{ + for my $method ( qw( PUT DELETE ) ) + { + my $req = Catalyst::Request::REST::ForBrowsers->new(); + $req->method('POST'); + $req->{_context} = 'MockContext'; + $req->header( 'x-http-method-override' => $method ); + + is( $req->method(), $method, + "$method - tunneled with x-http-method-override header" ); } }
Any progress?..