Klaus Demo nginx / 71d1f49
ngx_http_filter_finalize_request() and ngx_http_clean_header() Igor Sysoev 13 years ago
3 changed file(s) with 40 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
6363
6464 static ngx_int_t ngx_http_xslt_send(ngx_http_request_t *r,
6565 ngx_http_xslt_filter_ctx_t *ctx, ngx_buf_t *b);
66 static ngx_int_t ngx_http_xslt_filter_internal_error(ngx_http_request_t *r);
6766 static ngx_int_t ngx_http_xslt_add_chunk(ngx_http_request_t *r,
6867 ngx_http_xslt_filter_ctx_t *ctx, ngx_buf_t *b);
6968
319318 ctx->done = 1;
320319
321320 if (b == NULL) {
322 return ngx_http_xslt_filter_internal_error(r);
321 return ngx_http_filter_finalize_request(r,
322 NGX_HTTP_INTERNAL_SERVER_ERROR);
323323 }
324324
325325 cln = ngx_pool_cleanup_add(r->pool, 0);
326326
327327 if (cln == NULL) {
328328 ngx_free(b->pos);
329 return ngx_http_special_response_handler(r,
329 return ngx_http_filter_finalize_request(r,
330330 NGX_HTTP_INTERNAL_SERVER_ERROR);
331331 }
332332
355355 out.next = NULL;
356356
357357 return ngx_http_next_body_filter(r, &out);
358 }
359
360
361 static ngx_int_t
362 ngx_http_xslt_filter_internal_error(ngx_http_request_t *r)
363 {
364 ngx_int_t rc;
365
366 /* clear the modules contexts */
367 ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
368
369 rc = ngx_http_special_response_handler(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
370
371 /* NGX_ERROR resets any pending data */
372
373 return (rc == NGX_OK) ? NGX_ERROR : rc;
374358 }
375359
376360
102102 ngx_int_t ngx_http_send_header(ngx_http_request_t *r);
103103 ngx_int_t ngx_http_special_response_handler(ngx_http_request_t *r,
104104 ngx_int_t error);
105 ngx_int_t ngx_http_filter_finalize_request(ngx_http_request_t *r,
106 ngx_int_t error);
107 void ngx_http_clean_header(ngx_http_request_t *r);
105108
106109
107110 time_t ngx_http_parse_time(u_char *value, size_t len);
444444 }
445445
446446
447 ngx_int_t
448 ngx_http_filter_finalize_request(ngx_http_request_t *r, ngx_int_t error)
449 {
450 ngx_int_t rc;
451
452 ngx_http_clean_header(r);
453
454 /* clear the modules contexts */
455 ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
456
457 rc = ngx_http_special_response_handler(r, error);
458
459 /* NGX_ERROR resets any pending data */
460
461 return (rc == NGX_OK) ? NGX_ERROR : rc;
462 }
463
464
465 void
466 ngx_http_clean_header(ngx_http_request_t *r)
467 {
468 ngx_memzero(&r->headers_out.status,
469 sizeof(ngx_http_headers_out_t)
470 - offsetof(ngx_http_headers_out_t, status));
471
472 r->headers_out.headers.part.nelts = 0;
473 r->headers_out.headers.part.next = NULL;
474 r->headers_out.headers.last = &r->headers_out.headers.part;
475
476 r->headers_out.content_length_n = -1;
477 r->headers_out.last_modified_time = -1;
478 }
479
480
447481 static ngx_int_t
448482 ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page)
449483 {