mirror of
https://github.com/nginx/nginx.git
synced 2024-12-27 17:31:35 -06:00
allow to pass image filter errors via the same location where the filter is set
This commit is contained in:
parent
8bb39121fc
commit
ad0b9303d0
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user