allow override redirect status in error_page

This commit is contained in:
Igor Sysoev 2010-10-18 10:14:00 +00:00
parent c5d1790e1d
commit a64b716b22
2 changed files with 7 additions and 9 deletions

View File

@ -4069,19 +4069,15 @@ ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
if (overwrite >= 0) { err->overwrite = overwrite;
err->overwrite = overwrite;
} else { if (overwrite == -1) {
switch (err->status) { switch (err->status) {
case NGX_HTTP_TO_HTTPS: case NGX_HTTP_TO_HTTPS:
case NGX_HTTPS_CERT_ERROR: case NGX_HTTPS_CERT_ERROR:
case NGX_HTTPS_NO_CERT: case NGX_HTTPS_NO_CERT:
err->overwrite = NGX_HTTP_BAD_REQUEST; err->overwrite = NGX_HTTP_BAD_REQUEST;
break;
default: default:
err->overwrite = err->status;
break; break;
} }
} }

View File

@ -523,7 +523,9 @@ ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page)
r->expect_tested = 1; r->expect_tested = 1;
} }
r->err_status = overwrite; if (overwrite >= 0) {
r->err_status = overwrite;
}
if (ngx_http_complex_value(r, &err_page->value, &uri) != NGX_OK) { if (ngx_http_complex_value(r, &err_page->value, &uri) != NGX_OK) {
return NGX_ERROR; return NGX_ERROR;
@ -556,7 +558,7 @@ ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page)
return NGX_ERROR; return NGX_ERROR;
} }
r->err_status = NGX_HTTP_MOVED_TEMPORARILY; r->err_status = overwrite > 0 ? overwrite : NGX_HTTP_MOVED_TEMPORARILY;
location->hash = 1; location->hash = 1;
ngx_str_set(&location->key, "Location"); ngx_str_set(&location->key, "Location");
@ -570,7 +572,7 @@ ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page)
return ngx_http_send_refresh(r); return ngx_http_send_refresh(r);
} }
return ngx_http_send_special_response(r, clcf, NGX_HTTP_MOVED_TEMPORARILY return ngx_http_send_special_response(r, clcf, r->err_status
- NGX_HTTP_MOVED_PERMANENTLY - NGX_HTTP_MOVED_PERMANENTLY
+ NGX_HTTP_LEVEL_200); + NGX_HTTP_LEVEL_200);
} }