Klaus Demo nginx / ad0b930
allow to pass image filter errors via the same location where the filter is set Igor Sysoev 13 years ago
4 changed file(s) with 25 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
180180 return NGX_ERROR;
181181 }
182182
183 ctx = ngx_http_get_module_ctx(r, ngx_http_image_filter_module);
184
185 if (ctx) {
186 ngx_http_set_ctx(r, NULL, ngx_http_image_filter_module);
187 return ngx_http_next_header_filter(r);
188 }
189
183190 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_image_filter_ctx_t));
184191 if (ctx == NULL) {
185192 return NGX_ERROR;
257264 }
258265
259266 return ngx_http_filter_finalize_request(r,
267 &ngx_http_image_filter_module,
260268 NGX_HTTP_UNSUPPORTED_MEDIA_TYPE);
261269 }
262270
286294
287295 if (rc == NGX_ERROR) {
288296 return ngx_http_filter_finalize_request(r,
297 &ngx_http_image_filter_module,
289298 NGX_HTTP_UNSUPPORTED_MEDIA_TYPE);
290299 }
291300
297306
298307 if (out.buf == NULL) {
299308 return ngx_http_filter_finalize_request(r,
309 &ngx_http_image_filter_module,
300310 NGX_HTTP_UNSUPPORTED_MEDIA_TYPE);
301311 }
302312
318318 ctx->done = 1;
319319
320320 if (b == NULL) {
321 return ngx_http_filter_finalize_request(r,
321 return ngx_http_filter_finalize_request(r, NULL,
322322 NGX_HTTP_INTERNAL_SERVER_ERROR);
323323 }
324324
326326
327327 if (cln == NULL) {
328328 ngx_free(b->pos);
329 return ngx_http_filter_finalize_request(r,
329 return ngx_http_filter_finalize_request(r, NULL,
330330 NGX_HTTP_INTERNAL_SERVER_ERROR);
331331 }
332332
103103 ngx_int_t ngx_http_special_response_handler(ngx_http_request_t *r,
104104 ngx_int_t error);
105105 ngx_int_t ngx_http_filter_finalize_request(ngx_http_request_t *r,
106 ngx_int_t error);
106 ngx_module_t *m, ngx_int_t error);
107107 void ngx_http_clean_header(ngx_http_request_t *r);
108108
109109
445445
446446
447447 ngx_int_t
448 ngx_http_filter_finalize_request(ngx_http_request_t *r, ngx_int_t error)
448 ngx_http_filter_finalize_request(ngx_http_request_t *r, ngx_module_t *m,
449 ngx_int_t error)
449450 {
450 ngx_int_t rc;
451 void *ctx;
452 ngx_int_t rc;
451453
452454 ngx_http_clean_header(r);
455
456 if (m) {
457 ctx = r->ctx[m->ctx_index];
458 }
453459
454460 /* clear the modules contexts */
455461 ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
462
463 if (m) {
464 r->ctx[m->ctx_index] = ctx;
465 }
456466
457467 r->filter_finalize = 1;
458468