[PATCH] Added support for the 308 Permanent Redirect

Simon Leblanc contact at leblanc-simon.eu
Tue Apr 11 01:48:12 UTC 2017


# HG changeset patch
# User Simon Leblanc <contact at leblanc-simon.eu>
# Date 1491873226 -7200
#      Tue Apr 11 03:13:46 2017 +0200
# Node ID 3a823d3fcd1cea201c3839e5b960acbfdb7baf87
# Parent  29ba1d6a2da9320e68ef2b7a2516c4c424672ea8
Added support for the 308 Permanent Redirect

diff -r 29ba1d6a2da9 -r 3a823d3fcd1c src/http/modules/ngx_http_headers_filter_module.c
--- a/src/http/modules/ngx_http_headers_filter_module.c	Tue Apr 04 18:01:57 2017 +0300
+++ b/src/http/modules/ngx_http_headers_filter_module.c	Tue Apr 11 03:13:46 2017 +0200
@@ -173,6 +173,7 @@
     case NGX_HTTP_SEE_OTHER:
     case NGX_HTTP_NOT_MODIFIED:
     case NGX_HTTP_TEMPORARY_REDIRECT:
+    case NGX_HTTP_PERMANENT_REDIRECT:
         safe_status = 1;
         break;
 
diff -r 29ba1d6a2da9 -r 3a823d3fcd1c src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c	Tue Apr 04 18:01:57 2017 +0300
+++ b/src/http/ngx_http_core_module.c	Tue Apr 11 03:13:46 2017 +0200
@@ -1894,7 +1894,8 @@
     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);
 
diff -r 29ba1d6a2da9 -r 3a823d3fcd1c src/http/ngx_http_header_filter_module.c
--- a/src/http/ngx_http_header_filter_module.c	Tue Apr 04 18:01:57 2017 +0300
+++ b/src/http/ngx_http_header_filter_module.c	Tue Apr 11 03:13:46 2017 +0200
@@ -75,8 +75,9 @@
     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"),
diff -r 29ba1d6a2da9 -r 3a823d3fcd1c src/http/ngx_http_request.h
--- a/src/http/ngx_http_request.h	Tue Apr 04 18:01:57 2017 +0300
+++ b/src/http/ngx_http_request.h	Tue Apr 11 03:13:46 2017 +0200
@@ -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
diff -r 29ba1d6a2da9 -r 3a823d3fcd1c src/http/ngx_http_special_response.c
--- a/src/http/ngx_http_special_response.c	Tue Apr 04 18:01:57 2017 +0300
+++ b/src/http/ngx_http_special_response.c	Tue Apr 11 03:13:46 2017 +0200
@@ -89,6 +89,14 @@
 ;
 
 
+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 @@
     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 @@
     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;
     }


More information about the nginx-devel mailing list