Hi. I have problem with flattening brigades. I don't really know why Solution 1 works and Solution 2 gives segfaults/empty page in browsers. Could anyone explain that step by step what is wrong with solution 2? I actually couldn't find any info about it. Sorry, code formating is awful. Here they are: Solution 1: // not all variables are mentioned in code... static apr_status_t my_filter(ap_filter_t *f, apr_bucket_brigade *bb) { ctx->b = apr_brigade_create(r->pool, r->connection->bucket_alloc); for (b = APR_BRIGADE_FIRST(bb); b != APR_BRIGADE_SENTINEL(bb); b = APR_BUCKET_NEXT(b)) { if(APR_BUCKET_IS_FLUSH(b)) { continue; } if(APR_BUCKET_IS_EOS(b)) { ap_fputs(f->next, ctx->b, ctx->output); APR_BUCKET_REMOVE(b); APR_BRIGADE_INSERT_TAIL(ctx->b, b); return ap_pass_brigade(f->next, ctx->b); } apr_bucket_read(b, &buffer, &length, APR_BLOCK_READ); ctx->input = apr_psprintf(r->pool,"%s%.*s", ctx->input, length, buffer); } apr_brigade_destroy(bb); return APR_SUCCESS; } Solution 2: static apr_status_t my_filter(ap_filter_t *f, apr_bucket_brigade *bb) { char *c; apr_size_t s; apr_brigade_pflatten(bb, &c, &s, f->r->pool); apr_brigade_cleanup(bb); ap_fputs(f->next, bb, c); apr_bucket *b = apr_bucket_eos_create(f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(bb, b); return ap_pass_brigade(f->next, bb); } Thanks in advance. Kind regards.