allow to pass image filter errors via the same location where the filter is set
Igor Sysoev
13 years ago
180 | 180 |
return NGX_ERROR;
|
181 | 181 |
}
|
182 | 182 |
|
|
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 |
|
183 | 190 |
ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_image_filter_ctx_t));
|
184 | 191 |
if (ctx == NULL) {
|
185 | 192 |
return NGX_ERROR;
|
|
257 | 264 |
}
|
258 | 265 |
|
259 | 266 |
return ngx_http_filter_finalize_request(r,
|
|
267 |
&ngx_http_image_filter_module,
|
260 | 268 |
NGX_HTTP_UNSUPPORTED_MEDIA_TYPE);
|
261 | 269 |
}
|
262 | 270 |
|
|
286 | 294 |
|
287 | 295 |
if (rc == NGX_ERROR) {
|
288 | 296 |
return ngx_http_filter_finalize_request(r,
|
|
297 |
&ngx_http_image_filter_module,
|
289 | 298 |
NGX_HTTP_UNSUPPORTED_MEDIA_TYPE);
|
290 | 299 |
}
|
291 | 300 |
|
|
297 | 306 |
|
298 | 307 |
if (out.buf == NULL) {
|
299 | 308 |
return ngx_http_filter_finalize_request(r,
|
|
309 |
&ngx_http_image_filter_module,
|
300 | 310 |
NGX_HTTP_UNSUPPORTED_MEDIA_TYPE);
|
301 | 311 |
}
|
302 | 312 |
|
318 | 318 |
ctx->done = 1;
|
319 | 319 |
|
320 | 320 |
if (b == NULL) {
|
321 | |
return ngx_http_filter_finalize_request(r,
|
|
321 |
return ngx_http_filter_finalize_request(r, NULL,
|
322 | 322 |
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
323 | 323 |
}
|
324 | 324 |
|
|
326 | 326 |
|
327 | 327 |
if (cln == NULL) {
|
328 | 328 |
ngx_free(b->pos);
|
329 | |
return ngx_http_filter_finalize_request(r,
|
|
329 |
return ngx_http_filter_finalize_request(r, NULL,
|
330 | 330 |
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
331 | 331 |
}
|
332 | 332 |
|
103 | 103 |
ngx_int_t ngx_http_special_response_handler(ngx_http_request_t *r,
|
104 | 104 |
ngx_int_t error);
|
105 | 105 |
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);
|
107 | 107 |
void ngx_http_clean_header(ngx_http_request_t *r);
|
108 | 108 |
|
109 | 109 |
|
445 | 445 |
|
446 | 446 |
|
447 | 447 |
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)
|
449 | 450 |
{
|
450 | |
ngx_int_t rc;
|
|
451 |
void *ctx;
|
|
452 |
ngx_int_t rc;
|
451 | 453 |
|
452 | 454 |
ngx_http_clean_header(r);
|
|
455 |
|
|
456 |
if (m) {
|
|
457 |
ctx = r->ctx[m->ctx_index];
|
|
458 |
}
|
453 | 459 |
|
454 | 460 |
/* clear the modules contexts */
|
455 | 461 |
ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
|
|
462 |
|
|
463 |
if (m) {
|
|
464 |
r->ctx[m->ctx_index] = ctx;
|
|
465 |
}
|
456 | 466 |
|
457 | 467 |
r->filter_finalize = 1;
|
458 | 468 |
|