static ngx_int_t check_output_filter( ngx_http_request_t* r, ngx_http_foo_ctx_t *ctx )
{
ngx_chain_t * chain_flush = NULL;
chain_flush = ngx_chain_get_free_buf( r->pool, &ctx->free );
if ( chain_flush == NULL ) {
return NGX_ERROR;
}
chain_flush->buf->pos = 0;
chain_flush->buf->last = 0;
chain_flush->buf->start = 0;
chain_flush->buf->end = 0;
chain_flush->buf->in_file = 0;
chain_flush->buf->memory = 0;
chain_flush->buf->flush = 1;
chain_flush->buf->last_in_chain = 1;
chain_flush->buf->tag = (ngx_buf_tag_t) &ngx_http_foo_module;
ngx_int_t rc = ngx_http_output_filter(r, chain_flush);
if ( rc != NGX_AGAIN && rc != NGX_OK ) {
return NGX_ERROR;
}
ngx_chain_update_chains(r->pool, &ctx->free, &ctx->busy, &chain_flush, (ngx_buf_tag_t) &ngx_http_foo_module);
return rc;
}