Re: Filter or Handler to look at content length and return custom error message suggestion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 17, 2010 at 4:50 PM, Eric Covener <covener@xxxxxxxxx> wrote:
> On Wed, Nov 17, 2010 at 5:58 PM, Mohit Anchlia <mohitanchlia@xxxxxxxxx> wrote:
>> Apache 2:
>>
>> I have a requirement to look at content length and if it is greatar
>> than desired size then return error message. So psuedo code is like:
>>
>> if content_length > 32G
>> then
>>   if url contains /abc/
>>   then
>>       echo "0|abc|Bad length" # pipe delimited format that some
>> clients api support
>>   else if url contains /def/
>>       echo "<xml><message>Bad request</message><xml>" # client supporting XML
>>   fi
>> fi
>>
>> I first thought of using LimitRequestBody but that didn't work for me.
>> So now I am thinking if I can use filter or handlers. Does anyone know
>> if I can use filters that is read the lenght and the url and then
>> return the response instead of continuing down the chain.
>>
>> P.S. Note: Our requests are mod-jk requests. So if content length
>> check succeeds then hand over the request to mod jk workers wihch then
>> send it to jboss app server.
>>
>
> If you know this stuff is not chunked, you can do a simpler
> post_read_request hook and return 413 from it.

I haven't used handlers or filters before in Apache. Searching online
I see I can make use of "PerlPostReadRequestHandler" and may be read
the content length. But I have few more quesitons:

1. After the request is read and if I find content length > x then how
do I create the response and return from there without sending the
request to mod-jk worker
2. If I find content length is ok and want to continue sending the
request to mod_jk worker then how do I do that.
3. In the handler can I also generate custom response text?

>
> If it might be chunked, it should be relatively easy to rip the guts
> out something like mod_deflate's input filter and teach it to count
> bytes / return an error.
>
> --
> Eric Covener
> covener@xxxxxxxxx
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
>   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
>
>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx




[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux