Mercurial > hg > nginx-quic
diff src/http/ngx_http_special_response.c @ 176:c0552e5ab567
nginx-0.0.1-2003-11-09-23:03:38 import; separate building
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 09 Nov 2003 20:03:38 +0000 |
parents | 894a01c6aea3 |
children | 9f3a78b06c48 |
line wrap: on
line diff
--- a/src/http/ngx_http_special_response.c +++ b/src/http/ngx_http_special_response.c @@ -168,9 +168,10 @@ static ngx_str_t error_pages[] = { int ngx_http_special_response_handler(ngx_http_request_t *r, int error) { - int err, rc; + int err, rc, i; ngx_hunk_t *h; ngx_chain_t *out, **ll, *cl; + ngx_http_err_page_t *err_page; ngx_http_core_loc_conf_t *clcf; rc = ngx_http_discard_body(r); @@ -181,19 +182,6 @@ int ngx_http_special_response_handler(ng r->headers_out.status = error; - if (error < NGX_HTTP_BAD_REQUEST) { - /* 3XX */ - err = error - NGX_HTTP_MOVED_PERMANENTLY; - - } else if (error < NGX_HTTP_INTERNAL_SERVER_ERROR) { - /* 4XX */ - err = error - NGX_HTTP_BAD_REQUEST + 3; - - } else { - /* 5XX */ - err = error - NGX_HTTP_INTERNAL_SERVER_ERROR + 3 + 17; - } - if (r->keepalive != 0) { switch (error) { case NGX_HTTP_BAD_REQUEST: @@ -213,6 +201,31 @@ int ngx_http_special_response_handler(ng } } + clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); + + if (!r->error_page && clcf->error_pages) { + err_page = clcf->error_pages->elts; + for (i = 0; i < clcf->error_pages->nelts; i++) { + if (err_page[i].code == error) { + r->error_page = 1; + return ngx_http_internal_redirect(r, &err_page[i].uri, NULL); + } + } + } + + if (error < NGX_HTTP_BAD_REQUEST) { + /* 3XX */ + err = error - NGX_HTTP_MOVED_PERMANENTLY; + + } else if (error < NGX_HTTP_INTERNAL_SERVER_ERROR) { + /* 4XX */ + err = error - NGX_HTTP_BAD_REQUEST + 3; + + } else { + /* 5XX */ + err = error - NGX_HTTP_INTERNAL_SERVER_ERROR + 3 + 17; + } + if (error_pages[err].len) { r->headers_out.content_length_n = error_pages[err].len + sizeof(error_tail) - 1 @@ -272,8 +285,6 @@ int ngx_http_special_response_handler(ng ngx_alloc_link_and_set_hunk(cl, h, r->pool, NGX_ERROR); ngx_chain_add_link(out, ll, cl); - clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); - if (clcf->msie_padding && r->http_version >= NGX_HTTP_VERSION_10 && error >= NGX_HTTP_BAD_REQUEST