diff options
Diffstat (limited to 'src/http')
-rw-r--r-- | src/http/ngx_http_core_module.c | 12 | ||||
-rw-r--r-- | src/http/ngx_http_parse_time.c | 14 | ||||
-rw-r--r-- | src/http/ngx_http_request.h | 2 | ||||
-rw-r--r-- | src/http/ngx_http_special_response.c | 5 |
4 files changed, 20 insertions, 13 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 3a0ec8bfc..3f19b7833 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -429,7 +429,7 @@ int ngx_http_send_header(ngx_http_request_t *r) return NGX_OK; } - if (r->err_status) { + if (r->err_ctx) { r->headers_out.status = r->err_status; r->headers_out.status_line.len = 0; } @@ -499,17 +499,19 @@ int ngx_http_internal_redirect(ngx_http_request_t *r, } } - /* clear the modules contexts */ + if (r->err_ctx) { + + /* allocate the new modules contexts */ - if (r->error_page) { - r->err_status = r->headers_out.status; - r->err_ctx = r->ctx; r->ctx = ngx_pcalloc(r->pool, sizeof(void *) * ngx_http_max_module); if (r->ctx == NULL) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } } else { + + /* clear the modules contexts */ + ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module); } diff --git a/src/http/ngx_http_parse_time.c b/src/http/ngx_http_parse_time.c index 09e56b4f0..26deb2841 100644 --- a/src/http/ngx_http_parse_time.c +++ b/src/http/ngx_http_parse_time.c @@ -232,16 +232,22 @@ time_t ngx_http_parse_time(char *value, size_t len) return NGX_ERROR; } - /* shift new year to 1st March, needed for Gauss's formula */ + /* shift new year to March 1, needed for Gauss's formula */ + if (--month <= 0) { month += 12; year -= 1; } - /* Gauss's formula for Grigorian days from 1 March 1 BC */ + + /* Gauss's formula for Grigorian days from 1 March 1 BC */ + return (365 * year + year / 4 - year / 100 + year / 400 + 367 * month / 12 + day - 31 - /* 719527 days are between 1 March 1 BC and 1 March 1970, - 31 and 28 days in Jan and Feb 1970 */ + /* + * 719527 days are between March 1, 1 BC and March 1, 1970, + * 31 and 28 days in January and February 1970 + */ + - 719527 + 31 + 28) * 86400 + hour * 3600 + min * 60 + sec; } diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h index a87c6dc4e..a91dbea57 100644 --- a/src/http/ngx_http_request.h +++ b/src/http/ngx_http_request.h @@ -205,8 +205,6 @@ struct ngx_http_request_s { unsigned bypass_cache:1; unsigned no_cache:1; - unsigned error_page:1; - #if 0 unsigned cachable:1; #endif diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c index c1cb23aa4..8e93e90ce 100644 --- a/src/http/ngx_http_special_response.c +++ b/src/http/ngx_http_special_response.c @@ -203,11 +203,12 @@ int ngx_http_special_response_handler(ngx_http_request_t *r, int error) clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); - if (!r->error_page && clcf->error_pages) { + if (r->err_ctx == NULL && 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; + r->err_status = error; + r->err_ctx = r->ctx; return ngx_http_internal_redirect(r, &err_page[i].uri, NULL); } } |