httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Callahan <>
Subject 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 06:27:48 GMT
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.

Thank you.

    int my_declining_handler(request_rec *r) {
        apr_status_t status;
        int end = 0;
        apr_size_t bytes, count = 0;
        const char *buf;
        apr_bucket *b;
        apr_bucket_brigade *temp_brigade;

        // here: header check for content-length/transfer encoding

        temp_brigade = apr_brigade_create(r->pool,
        do {
            status = ap_get_brigade(r->input_filters, temp_brigade,
            if (status == APR_SUCCESS) {/* Loop over the contents of
temp_brigade */
                for (b = APR_BRIGADE_FIRST(temp_brigade);
                     b != APR_BRIGADE_SENTINEL(temp_brigade);
                     b = APR_BUCKET_NEXT(b)) {
                    if (APR_BUCKET_IS_EOS(b)) {
                        end = 1;
                    else if (APR_BUCKET_IS_METADATA(b)) {
                    bytes = BUFLEN;
                    status = apr_bucket_read(b, &buf, &bytes,
                    count += bytes;

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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message