httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Kew <>
Subject Re: How to read data in a request handler and then return DECLINED without consuming the data in the bucket brigade?
Date Mon, 04 Jun 2018 09:12:20 GMT

> On 4 Jun 2018, at 08:55, Sorin Manolache <> wrote:
> On 2018-06-04 08:27, Paul Callahan wrote:
>> In apache modules, my understanding is if a handler declines a request, the
>> request is passed on to the next suitable handler.   I'm finding though if
>> I read the bucket_brigade/request body, and then decline the request, the
>> subsequent handler doesn't get any data.  It is like the act of reading the
>> bucket brigade consumes it.
>> I would like to have a request handler read the data, do some task (in this
>> case just count bytes), and decline the request without consuming the data
>> for the next handler.

Why is that a handler?  An input filter could count the data and pass them
straight down the chain, avoiding any such problem.  At a glance, your code
would need very little modification to work as a filter.

Exhortation: work with the server architecture, not against it!

> Hello,
> As far as I know, there is no simple way to do that.

This is true, in the sense that data get consumed.  To do otherwise would be
monstrously inefficient, and turn a big request body straight into a DoS.

This is why we have mod_request.  It provides an input filter you can use
explicitly to buffer data which then remain available to the next module to read them.
Use with caution: for example, if you fail to limit request size, you could find
yourself trying to buffer gigabytes of request data.

>>         } while (!end && (status == APR_SUCCESS));
>>         if (status == APR_SUCCESS) {
>>             return DECLINED;
>>         } else {
>>             return HTTP_INTERNAL_SERVER_ERROR;
>>         }
>>     }

Minor tip there: you're turning EAGAIN into a fatal error.

Nick Kew
View raw message