aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/http/modules/ngx_http_image_filter_module.c10
-rw-r--r--src/http/modules/ngx_http_xslt_filter_module.c4
-rw-r--r--src/http/ngx_http.h2
-rw-r--r--src/http/ngx_http_special_response.c14
4 files changed, 25 insertions, 5 deletions
diff --git a/src/http/modules/ngx_http_image_filter_module.c b/src/http/modules/ngx_http_image_filter_module.c
index c68ecb510..83fc1459e 100644
--- a/src/http/modules/ngx_http_image_filter_module.c
+++ b/src/http/modules/ngx_http_image_filter_module.c
@@ -181,6 +181,13 @@ ngx_http_image_header_filter(ngx_http_request_t *r)
return NGX_ERROR;
}
+ ctx = ngx_http_get_module_ctx(r, ngx_http_image_filter_module);
+
+ if (ctx) {
+ ngx_http_set_ctx(r, NULL, ngx_http_image_filter_module);
+ return ngx_http_next_header_filter(r);
+ }
+
ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_image_filter_ctx_t));
if (ctx == NULL) {
return NGX_ERROR;
@@ -258,6 +265,7 @@ ngx_http_image_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
}
return ngx_http_filter_finalize_request(r,
+ &ngx_http_image_filter_module,
NGX_HTTP_UNSUPPORTED_MEDIA_TYPE);
}
@@ -287,6 +295,7 @@ ngx_http_image_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
if (rc == NGX_ERROR) {
return ngx_http_filter_finalize_request(r,
+ &ngx_http_image_filter_module,
NGX_HTTP_UNSUPPORTED_MEDIA_TYPE);
}
@@ -298,6 +307,7 @@ ngx_http_image_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
if (out.buf == NULL) {
return ngx_http_filter_finalize_request(r,
+ &ngx_http_image_filter_module,
NGX_HTTP_UNSUPPORTED_MEDIA_TYPE);
}
diff --git a/src/http/modules/ngx_http_xslt_filter_module.c b/src/http/modules/ngx_http_xslt_filter_module.c
index 4759308c2..220400c83 100644
--- a/src/http/modules/ngx_http_xslt_filter_module.c
+++ b/src/http/modules/ngx_http_xslt_filter_module.c
@@ -319,7 +319,7 @@ ngx_http_xslt_send(ngx_http_request_t *r, ngx_http_xslt_filter_ctx_t *ctx,
ctx->done = 1;
if (b == NULL) {
- return ngx_http_filter_finalize_request(r,
+ return ngx_http_filter_finalize_request(r, NULL,
NGX_HTTP_INTERNAL_SERVER_ERROR);
}
@@ -327,7 +327,7 @@ ngx_http_xslt_send(ngx_http_request_t *r, ngx_http_xslt_filter_ctx_t *ctx,
if (cln == NULL) {
ngx_free(b->pos);
- return ngx_http_filter_finalize_request(r,
+ return ngx_http_filter_finalize_request(r, NULL,
NGX_HTTP_INTERNAL_SERVER_ERROR);
}
diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h
index 2c442be9f..9444b1131 100644
--- a/src/http/ngx_http.h
+++ b/src/http/ngx_http.h
@@ -104,7 +104,7 @@ ngx_int_t ngx_http_send_header(ngx_http_request_t *r);
ngx_int_t ngx_http_special_response_handler(ngx_http_request_t *r,
ngx_int_t error);
ngx_int_t ngx_http_filter_finalize_request(ngx_http_request_t *r,
- ngx_int_t error);
+ ngx_module_t *m, ngx_int_t error);
void ngx_http_clean_header(ngx_http_request_t *r);
diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
index 8f0a2078d..9bf99162b 100644
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -446,15 +446,25 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
ngx_int_t
-ngx_http_filter_finalize_request(ngx_http_request_t *r, ngx_int_t error)
+ngx_http_filter_finalize_request(ngx_http_request_t *r, ngx_module_t *m,
+ ngx_int_t error)
{
- ngx_int_t rc;
+ void *ctx;
+ ngx_int_t rc;
ngx_http_clean_header(r);
+ if (m) {
+ ctx = r->ctx[m->ctx_index];
+ }
+
/* clear the modules contexts */
ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
+ if (m) {
+ r->ctx[m->ctx_index] = ctx;
+ }
+
r->filter_finalize = 1;
rc = ngx_http_special_response_handler(r, error);