ngx_http_filter_finalize_request() and ngx_http_clean_header()
Igor Sysoev
13 years ago
63 | 63 |
|
64 | 64 |
static ngx_int_t ngx_http_xslt_send(ngx_http_request_t *r,
|
65 | 65 |
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);
|
67 | 66 |
static ngx_int_t ngx_http_xslt_add_chunk(ngx_http_request_t *r,
|
68 | 67 |
ngx_http_xslt_filter_ctx_t *ctx, ngx_buf_t *b);
|
69 | 68 |
|
|
319 | 318 |
ctx->done = 1;
|
320 | 319 |
|
321 | 320 |
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);
|
323 | 323 |
}
|
324 | 324 |
|
325 | 325 |
cln = ngx_pool_cleanup_add(r->pool, 0);
|
326 | 326 |
|
327 | 327 |
if (cln == NULL) {
|
328 | 328 |
ngx_free(b->pos);
|
329 | |
return ngx_http_special_response_handler(r,
|
|
329 |
return ngx_http_filter_finalize_request(r,
|
330 | 330 |
NGX_HTTP_INTERNAL_SERVER_ERROR);
|
331 | 331 |
}
|
332 | 332 |
|
|
355 | 355 |
out.next = NULL;
|
356 | 356 |
|
357 | 357 |
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;
|
374 | 358 |
}
|
375 | 359 |
|
376 | 360 |
|
102 | 102 |
ngx_int_t ngx_http_send_header(ngx_http_request_t *r);
|
103 | 103 |
ngx_int_t ngx_http_special_response_handler(ngx_http_request_t *r,
|
104 | 104 |
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);
|
105 | 108 |
|
106 | 109 |
|
107 | 110 |
time_t ngx_http_parse_time(u_char *value, size_t len);
|
444 | 444 |
}
|
445 | 445 |
|
446 | 446 |
|
|
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 |
|
447 | 481 |
static ngx_int_t
|
448 | 482 |
ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page)
|
449 | 483 |
{
|