Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Limit URL length with Dancer/Starman ( Plack::Middleware::ProhibitRequestUri8190 )

by Anonymous Monk
on Nov 08, 2013 at 00:51 UTC ( #1061650=note: print w/ replies, xml ) Need Help??


in reply to SOLVED: Limit URL length with Dancer/Starman

How big is this URL you request?

Is there a way to throw a 414 and avoid this behavior when Dancer running under Starman?

Sure, add a check for URI size first in line :) http://search.cpan.org/dist/Dancer/lib/Dancer/Cookbook.pod#Default_route

(untested)

any qr{.{8190}.*} => sub { status '414'; # 414 - Request-URI Too Long };

Or make a Plack::Middleware to do the check

(untested)

package Plack::Middleware::ProhibitRequestUri8190; use parent qw(Plack::Middleware); use Plack::Util; sub call { my($self, $env) = @_; my $res = $self->app->($env); if( length $res->{REQUEST_URI} > 8190 ){ Plack::Util::response_cb($res, sub { my $res = shift; $res->[0] = 414; return; }); } }

plack middleware 414 request uri too large


Comment on Re: Limit URL length with Dancer/Starman ( Plack::Middleware::ProhibitRequestUri8190 )
Select or Download Code
Re^2: Limit URL length with Dancer/Starman ( Plack::Middleware::ProhibitRequestUri8190 )
by gsiems (Chaplain) on Nov 14, 2013 at 20:47 UTC

    Thanks.

    The default route doesn't appear to do the trick (see the updated question).

    So far I've had no luck with the plack middleware, although http://advent.perldancer.org/2010/22 looks promising (towards the bottom where they wrap the app).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1061650]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2014-12-29 00:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (183 votes), past polls