diff --git a/src/http/modules/ngx_http_ssi_filter_module.c b/src/http/modules/ngx_http_ssi_filter_module.c index 47068f755..cdb5356d4 100644 --- a/src/http/modules/ngx_http_ssi_filter_module.c +++ b/src/http/modules/ngx_http_ssi_filter_module.c @@ -2232,12 +2232,30 @@ ngx_http_ssi_include(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx, static ngx_int_t ngx_http_ssi_stub_output(ngx_http_request_t *r, void *data, ngx_int_t rc) { - ngx_chain_t *out; + ngx_chain_t *out; + ngx_http_ssi_ctx_t *ctx; if (rc == NGX_ERROR || r->connection->error || r->request_output) { return rc; } + ctx = ngx_http_get_module_ctx(r, ngx_http_ssi_filter_module); + + if (ctx && ctx->stub_output_done) { + return NGX_OK; + } + + if (ctx == NULL) { + ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_ssi_ctx_t)); + if (ctx == NULL) { + return NGX_ERROR; + } + + ngx_http_set_ctx(r, ctx, ngx_http_ssi_filter_module); + } + + ctx->stub_output_done = 1; + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "ssi stub output: \"%V?%V\"", &r->uri, &r->args); diff --git a/src/http/modules/ngx_http_ssi_filter_module.h b/src/http/modules/ngx_http_ssi_filter_module.h index 419bf977d..eb61040be 100644 --- a/src/http/modules/ngx_http_ssi_filter_module.h +++ b/src/http/modules/ngx_http_ssi_filter_module.h @@ -82,6 +82,8 @@ typedef struct { void *value_buf; ngx_str_t timefmt; ngx_str_t errmsg; + + ngx_uint_t stub_output_done; } ngx_http_ssi_ctx_t; diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index 3459d2726..3cca57cf5 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -2526,7 +2526,6 @@ ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc) if (r != r->main && r->post_subrequest) { rc = r->post_subrequest->handler(r, r->post_subrequest->data, rc); - r->post_subrequest = NULL; } if (rc == NGX_ERROR