]> git.kaiwu.me - nginx.git/commitdiff
Added support for the "308 Permanent Redirect" (ticket #877).
authorSimon Leblanc <contact@leblanc-simon.eu>
Tue, 11 Apr 2017 01:13:46 +0000 (03:13 +0200)
committerSimon Leblanc <contact@leblanc-simon.eu>
Tue, 11 Apr 2017 01:13:46 +0000 (03:13 +0200)
src/http/modules/ngx_http_headers_filter_module.c
src/http/modules/perl/nginx.pm
src/http/ngx_http_core_module.c
src/http/ngx_http_header_filter_module.c
src/http/ngx_http_request.h
src/http/ngx_http_special_response.c

index 6738afe9fbd0fdb22b3d41caff8940fbcf55416e..b5aac33a712cb0d22d5cf14daa4f07f9b005c61c 100644 (file)
@@ -173,6 +173,7 @@ ngx_http_headers_filter(ngx_http_request_t *r)
     case NGX_HTTP_SEE_OTHER:
     case NGX_HTTP_NOT_MODIFIED:
     case NGX_HTTP_TEMPORARY_REDIRECT:
+    case NGX_HTTP_PERMANENT_REDIRECT:
         safe_status = 1;
         break;
 
index e3f736110258df8e8fc20f56bf2c7c2ed4d17778..d4663dc3b4f0f18119dd1e7ad0332c8f28828a48 100644 (file)
@@ -24,6 +24,7 @@ our @EXPORT = qw(
     HTTP_SEE_OTHER
     HTTP_NOT_MODIFIED
     HTTP_TEMPORARY_REDIRECT
+    HTTP_PERMANENT_REDIRECT
 
     HTTP_BAD_REQUEST
     HTTP_UNAUTHORIZED
@@ -72,6 +73,7 @@ use constant HTTP_REDIRECT                  => 302;
 use constant HTTP_SEE_OTHER                 => 303;
 use constant HTTP_NOT_MODIFIED              => 304;
 use constant HTTP_TEMPORARY_REDIRECT        => 307;
+use constant HTTP_PERMANENT_REDIRECT        => 308;
 
 use constant HTTP_BAD_REQUEST               => 400;
 use constant HTTP_UNAUTHORIZED              => 401;
index 38df6ac1f0642ee82c951d6721e73d6c2b625011..f357ee4b688a6080fc15e862b96d7c7efdae7579 100644 (file)
@@ -1894,7 +1894,8 @@ ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status,
     if (status == NGX_HTTP_MOVED_PERMANENTLY
         || status == NGX_HTTP_MOVED_TEMPORARILY
         || status == NGX_HTTP_SEE_OTHER
-        || status == NGX_HTTP_TEMPORARY_REDIRECT)
+        || status == NGX_HTTP_TEMPORARY_REDIRECT
+        || status == NGX_HTTP_PERMANENT_REDIRECT)
     {
         ngx_http_clear_location(r);
 
index c09c5191c503f15ec73a670b0ac958eacbdbe7d1..5fc7e1f1b436addc7809eb59995f427752608623 100644 (file)
@@ -75,8 +75,9 @@ static ngx_str_t ngx_http_status_lines[] = {
     ngx_null_string,  /* "305 Use Proxy" */
     ngx_null_string,  /* "306 unused" */
     ngx_string("307 Temporary Redirect"),
+    ngx_string("308 Permanent Redirect"),
 
-#define NGX_HTTP_LAST_3XX  308
+#define NGX_HTTP_LAST_3XX  309
 #define NGX_HTTP_OFF_4XX   (NGX_HTTP_LAST_3XX - 301 + NGX_HTTP_OFF_3XX)
 
     ngx_string("400 Bad Request"),
index a68b90692e3d59c8abbedf8c7c74d1cd55b16d72..2c77f9323b9c9c0d5495a9a04c4d16e09c45d24e 100644 (file)
@@ -83,6 +83,7 @@
 #define NGX_HTTP_SEE_OTHER                 303
 #define NGX_HTTP_NOT_MODIFIED              304
 #define NGX_HTTP_TEMPORARY_REDIRECT        307
+#define NGX_HTTP_PERMANENT_REDIRECT        308
 
 #define NGX_HTTP_BAD_REQUEST               400
 #define NGX_HTTP_UNAUTHORIZED              401
index c9b1017274fd08bba9cedc9c1a1cc73f21718265..c4c13053b5853ca4824d3073d6ae053721c5d6fb 100644 (file)
@@ -89,6 +89,14 @@ static char ngx_http_error_307_page[] =
 ;
 
 
+static char ngx_http_error_308_page[] =
+"<html>" CRLF
+"<head><title>308 Permanent Redirect</title></head>" CRLF
+"<body bgcolor=\"white\">" CRLF
+"<center><h1>308 Permanent Redirect</h1></center>" CRLF
+;
+
+
 static char ngx_http_error_400_page[] =
 "<html>" CRLF
 "<head><title>400 Bad Request</title></head>" CRLF
@@ -336,8 +344,9 @@ static ngx_str_t ngx_http_error_pages[] = {
     ngx_null_string,                     /* 305 */
     ngx_null_string,                     /* 306 */
     ngx_string(ngx_http_error_307_page),
+    ngx_string(ngx_http_error_308_page),
 
-#define NGX_HTTP_LAST_3XX  308
+#define NGX_HTTP_LAST_3XX  309
 #define NGX_HTTP_OFF_4XX   (NGX_HTTP_LAST_3XX - 301 + NGX_HTTP_OFF_3XX)
 
     ngx_string(ngx_http_error_400_page),
@@ -615,7 +624,8 @@ ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page)
     if (overwrite != NGX_HTTP_MOVED_PERMANENTLY
         && overwrite != NGX_HTTP_MOVED_TEMPORARILY
         && overwrite != NGX_HTTP_SEE_OTHER
-        && overwrite != NGX_HTTP_TEMPORARY_REDIRECT)
+        && overwrite != NGX_HTTP_TEMPORARY_REDIRECT
+        && overwrite != NGX_HTTP_PERMANENT_REDIRECT)
     {
         r->err_status = NGX_HTTP_MOVED_TEMPORARILY;
     }