modperl_apr_strerror(rc)));
error));
MP_INLINE SSize_t modperl_request_read(pTHX_ request_rec *r,                                       char *buffer, Size_t len){    long total = 0;    int wanted = len;    int seen_eos = 0;    char *tmp = buffer;    apr_bucket_brigade *bb;    if (len <= 0) {        return 0;    }    bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);    if (bb == NULL) {        r->connection->keepalive = AP_CONN_CLOSE;        return -1;    }    do {        apr_size_t read;        int rc;        rc = ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES,                            APR_BLOCK_READ, len);        if (rc != APR_SUCCESS) {             /* if we fail here, we want to just return and stop trying             * to read data from the client.             */            r->connection->keepalive = AP_CONN_CLOSE;            apr_brigade_destroy(bb);            sv_setpv(ERRSV,                     (char *)apr_psprintf(r->pool,                                           "failed to get bucket brigade: %s",                                          modperl_apr_strerror(rc)));            return -1;        }        /* If this fails, it means that a filter is written         * incorrectly and that it needs to learn how to properly         * handle APR_BLOCK_READ requests by returning data when         * requested.         */        if (APR_BRIGADE_EMPTY(bb)) {            apr_brigade_destroy(bb);            /* we can't tell which filter is broken, since others may             * just pass data through */            sv_setpv(ERRSV, "Aborting read from client. "                     "One of the input filters is broken. "                     "It returned an empty bucket brigade for "                     "the APR_BLOCK_READ mode request");            return -1;        }        if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(bb))) {            seen_eos = 1;        }        read = len;        rc = apr_brigade_flatten(bb, tmp, &read);        if (rc != APR_SUCCESS) {            apr_brigade_destroy(bb);            sv_setpv(ERRSV,                     (char *)apr_psprintf(r->pool,                                           "failed to read: %s",                                          modperl_apr_strerror(rc)));            return -1;        }        total += read;        tmp   += read;        len   -= read;        /* XXX: what happens if the downstream filter returns more         * data than the caller has asked for? We can't return more         * data that requested, so it needs to be stored somewhere and         * dealt with on the subsequent calls to this function. or may         * be we should just assert, blaming a bad filter. at the         * moment I couldn't find a spec telling whether it's wrong         * for the filter to return more data than it was asked for in         * the AP_MODE_READBYTES mode.         */                apr_brigade_cleanup(bb);    } while (len > 0 && !seen_eos);    apr_brigade_destroy(bb);    MP_TRACE_o(MP_FUNC, "wanted %db, read %db [%s]", wanted, total,               IO_DUMP_FIRST_CHUNK(r->pool, buffer, total));    return total;}