around method => sub {
my $orig = shift;
my $self = shift;
return $self->$orig(@_)
if @_ || $self->_determined_real_method;
my $method = $self->$orig();
my $tunneled;
if ( defined $method && uc $method eq 'POST' ) {
$tunneled = $self->param('x-tunneled-method')
|| $self->header('x-http-method-override');
}
$self->$orig( defined $tunneled ? uc $tunneled : $method );
$self->_determined_real_method(1);
return $self->$orig();
};
This piece of code is from Catalyst::TraitFor::Request::REST::ForBrowsers I am using the action class REST::ForBrowsers and if a GET request is sent from a browser, methodname_GET_html gets called (otherwise just methodname_GET is called). However during a POST from a browser (and not sending x-tunneled-method or setting the x-http-method-override header) it is setting the boolean ($c->request->looks_like_browser) to 1, yet it calls the non browser sub methodname_POST (and not methodname_POST_html). I assume this is the problem piece of code since the trait is identifying the browser correctly.
Example:
sub user_GET_html : Private {
my($self, $c) = @_;
$c->log->debug('GET request from browser');
$c->log->debug('Called during browser GET requests only');
}
sub user_POST : Private {
my($self, $c) = @_;
$c->log->debug('POST request from non-browser');
$c->log->debug('But I do think its a browser. WTF mate?') if $c->r
+equest->looks_like_browser; #this should be false due to the method n
+ame we are in
}
sub user_POST_html : Private {
my($self, $c) = @_;
$c->log->debug('POST request from browser');
$c->log->debug(' Nobody ever calls me :( ');
}
EDIT: So the reason is because in Catalyst::Actin::REST it only checks the traits for a GET request. Is there some sort of reason for this?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.