From cacce525e5ed77612a2a9cd0cf455cd96eee8fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brane=20F=2E=20Gra=C4=8Dnar?= Date: Tue, 27 Mar 2012 18:20:05 +0200 Subject: [PATCH] Additional HTTP POST/PUT method robustness fix. --- lib/P9/AA/Protocol/HTTP.pm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/P9/AA/Protocol/HTTP.pm b/lib/P9/AA/Protocol/HTTP.pm index 6c5bef0..51c9da5 100644 --- a/lib/P9/AA/Protocol/HTTP.pm +++ b/lib/P9/AA/Protocol/HTTP.pm @@ -237,7 +237,15 @@ sub parse { $req = undef; goto outta_parse; } - + + # try to convert it into int + { no warnings; $cl += 0 } + # too big request body? + if ($cl > 1024 * 1024) { + $self->error("Request entity too big (413)."); + return undef; + } + # has client sent Expect request header? if (defined(my $e = $req->header('Expect'))) { $e = lc($e); @@ -246,16 +254,8 @@ sub parse { } } - # try to convert it into int - { no warnings; $cl += 0 } - # read content body if ($do_read && $cl > 0) { - # too big request body? - if ($cl > 1024 * 1024) { - $self->error("Request entity too big (413)."); - return undef; - } my $buf = ''; my $r = read($fd, $buf, $cl);