[cgiapp] REST tunneling in CGI::Application::Dispatch
Jaldhar H. Vyas
jaldhar at braincells.com
Wed May 11 22:16:46 EDT 2011
On Wed, 11 May 2011, Mark Stosberg wrote:
> Jaldhar,
>
> Could point out specifically where your auto-tunneling feature is in the
> plugin?
Oops. The tunneling code is actually in REST::Utils which C::A::P::REST
depends on. Here is the POD from that module.
=head3 request_method($cgi)
This function returns the query's HTTP request method.
Example 1:
my $method = request_method($cgi);
This function takes a L<CGI> or compatible object as its first parameter.
Because many web sites don't allow the full set of HTTP methods needed
for REST, you can "tunnel" methods through C<GET> or C<POST> requests in
the following ways:
In the query with the C<_method> parameter. This will work even with C<POST>
requests where parameters are usually passed in the request body.
Example 2:
http://localhost/index.cgi?_method=DELETE
Or with the C<X-HTTP-Method-Override> HTTP header.
Example 3:
X-HTTP-METHOD-OVERRIDE: PUT
if more than one of these are present, the HTTP header will override the query
parameter, which will override the "real" method.
Any method can be tunneled through a C<POST> request. Only C<GET> and C<HEAD>
can be tunneled through a C<GET> request. You cannot tunnel through a
C<HEAD>, C<PUT>, C<DELETE>, or any other request. If an invalid tunnel is
attempted, it will be ignored.
=cut
> You may want to add the keyword "tunneling" somewhere in the
> docs near where you document that feature.
Yes I will add it to the docs for the next version of C::A::P::REST.
--
Jaldhar H. Vyas <jaldhar at braincells.com>
More information about the cgiapp
mailing list