Welcome! Log In Create A New Profile

Advanced

[PATCH 2 of 5] Fix error_page status code change in redirect

Maxim Dounin
November 02, 2010 12:02AM
# HG changeset patch
# User Maxim Dounin <mdounin@mdounin.ru>
# Date 1288669812 -10800
# Node ID 49670f58d178cbef2108a76676b8d79cf2cb648b
# Parent 1e3045c3de6be5718359f4e0e3af9007f3da50aa
Fix error_page status code change in redirect.

Using codes other than 301, 302 and 303 resulted in unexpected behaviour. E.g.
something like

error_page 404 =200 http://localhost/;

resulted in "[alert] ... writev() failed (14: Bad address)" messages and no
reply returned. See here for initial report:

http://nginx.org/pipermail/nginx-ru/2010-October/037506.html

The same problem appears when redirecting special error codes which has
implict code changes, e.g. 497. See here for report:

http://nginx.org/pipermail/nginx/2010-November/023402.html

diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -557,7 +557,14 @@ ngx_http_send_error_page(ngx_http_reques
return NGX_ERROR;
}

- r->err_status = overwrite > 0 ? overwrite : NGX_HTTP_MOVED_TEMPORARILY;
+ if (overwrite >= NGX_HTTP_MOVED_PERMANENTLY
+ && overwrite < NGX_HTTP_LAST_LEVEL_300)
+ {
+ r->err_status = overwrite;
+
+ } else {
+ r->err_status = NGX_HTTP_MOVED_TEMPORARILY;
+ }

location->hash = 1;
ngx_str_set(&location->key, "Location");

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 2 of 5] Fix error_page status code change in redirect

Maxim Dounin 2527 November 02, 2010 12:02AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 69
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready