]> git.kaiwu.me - nginx.git/commitdiff
Added support for the 307 Temporary Redirect.
authorRuslan Ermilov <ru@nginx.com>
Mon, 27 Feb 2012 11:43:40 +0000 (11:43 +0000)
committerRuslan Ermilov <ru@nginx.com>
Mon, 27 Feb 2012 11:43:40 +0000 (11:43 +0000)
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 ff33f1f78121422e47c6674fa23819962427a8ee..e6cf3f42367933d7ed4753a6a816d55a0cda4532 100644 (file)
@@ -149,7 +149,9 @@ ngx_http_headers_filter(ngx_http_request_t *r)
             && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT
             && r->headers_out.status != NGX_HTTP_MOVED_PERMANENTLY
             && r->headers_out.status != NGX_HTTP_MOVED_TEMPORARILY
-            && r->headers_out.status != NGX_HTTP_NOT_MODIFIED))
+            && r->headers_out.status != NGX_HTTP_SEE_OTHER
+            && r->headers_out.status != NGX_HTTP_NOT_MODIFIED
+            && r->headers_out.status != NGX_HTTP_TEMPORARY_REDIRECT))
     {
         return ngx_http_next_header_filter(r);
     }
index 4248aacaa547a40209512f3f22f73df42db4ff7c..b6fbdfd4535bdcbf6fdc7a984c31da34a84078ef 100644 (file)
@@ -21,7 +21,9 @@ our @EXPORT = qw(
     HTTP_MOVED_PERMANENTLY
     HTTP_MOVED_TEMPORARILY
     HTTP_REDIRECT
+    HTTP_SEE_OTHER
     HTTP_NOT_MODIFIED
+    HTTP_TEMPORARY_REDIRECT
 
     HTTP_BAD_REQUEST
     HTTP_UNAUTHORIZED
@@ -67,7 +69,9 @@ use constant HTTP_PARTIAL_CONTENT           => 206;
 use constant HTTP_MOVED_PERMANENTLY         => 301;
 use constant HTTP_MOVED_TEMPORARILY         => 302;
 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_BAD_REQUEST               => 400;
 use constant HTTP_UNAUTHORIZED              => 401;
index 35b538b6e5bfdbb6b6d00ac48d42002e8cc8d3f8..96e999718fcc3c5ca28e133f73e47dec5be9bf4c 100644 (file)
@@ -1824,8 +1824,11 @@ ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status,
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
 
-    if (status >= NGX_HTTP_MOVED_PERMANENTLY && status <= NGX_HTTP_SEE_OTHER) {
-
+    if (status == NGX_HTTP_MOVED_PERMANENTLY
+        || status == NGX_HTTP_MOVED_TEMPORARILY
+        || status == NGX_HTTP_SEE_OTHER
+        || status == NGX_HTTP_TEMPORARY_REDIRECT)
+    {
         ngx_http_clear_location(r);
 
         r->headers_out.location = ngx_list_push(&r->headers_out.headers);
index 1d8fee9d72f708764fa84b77b7b02a0afde91b4a..8a6080f6008b2e51e7535169089824f5c4c4b84a 100644 (file)
@@ -71,12 +71,11 @@ static ngx_str_t ngx_http_status_lines[] = {
     ngx_string("302 Moved Temporarily"),
     ngx_string("303 See Other"),
     ngx_string("304 Not Modified"),
+    ngx_null_string,  /* "305 Use Proxy" */
+    ngx_null_string,  /* "306 unused" */
+    ngx_string("307 Temporary Redirect"),
 
-    /* ngx_null_string, */  /* "305 Use Proxy" */
-    /* ngx_null_string, */  /* "306 unused" */
-    /* ngx_null_string, */  /* "307 Temporary Redirect" */
-
-#define NGX_HTTP_LAST_3XX  305
+#define NGX_HTTP_LAST_3XX  308
 #define NGX_HTTP_OFF_4XX   (NGX_HTTP_LAST_3XX - 301 + NGX_HTTP_OFF_3XX)
 
     ngx_string("400 Bad Request"),
index 108dba92d7b226fdef26a25decc770031a290b34..17c4b1e66b0b29463c18cabc8dfb136a23c67fd0 100644 (file)
@@ -75,6 +75,7 @@
 #define NGX_HTTP_MOVED_TEMPORARILY         302
 #define NGX_HTTP_SEE_OTHER                 303
 #define NGX_HTTP_NOT_MODIFIED              304
+#define NGX_HTTP_TEMPORARY_REDIRECT        307
 
 #define NGX_HTTP_BAD_REQUEST               400
 #define NGX_HTTP_UNAUTHORIZED              401
index d481d090887eb6b521cb65d0d47fde4e8822f61e..77b3dd13fcc57271d911ae0878e82faa45e8a7fe 100644 (file)
@@ -74,6 +74,14 @@ static char ngx_http_error_303_page[] =
 ;
 
 
+static char ngx_http_error_307_page[] =
+"<html>" CRLF
+"<head><title>307 Temporary Redirect</title></head>" CRLF
+"<body bgcolor=\"white\">" CRLF
+"<center><h1>307 Temporary Redirect</h1></center>" CRLF
+;
+
+
 static char ngx_http_error_400_page[] =
 "<html>" CRLF
 "<head><title>400 Bad Request</title></head>" CRLF
@@ -301,8 +309,12 @@ static ngx_str_t ngx_http_error_pages[] = {
     ngx_string(ngx_http_error_301_page),
     ngx_string(ngx_http_error_302_page),
     ngx_string(ngx_http_error_303_page),
+    ngx_null_string,                     /* 304 */
+    ngx_null_string,                     /* 305 */
+    ngx_null_string,                     /* 306 */
+    ngx_string(ngx_http_error_307_page),
 
-#define NGX_HTTP_LAST_3XX  304
+#define NGX_HTTP_LAST_3XX  308
 #define NGX_HTTP_OFF_4XX   (NGX_HTTP_LAST_3XX - 301 + NGX_HTTP_OFF_3XX)
 
     ngx_string(ngx_http_error_400_page),
@@ -567,12 +579,11 @@ ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page)
         return NGX_ERROR;
     }
 
-    if (overwrite >= NGX_HTTP_MOVED_PERMANENTLY
-        && overwrite <= NGX_HTTP_SEE_OTHER)
+    if (overwrite != NGX_HTTP_MOVED_PERMANENTLY
+        && overwrite != NGX_HTTP_MOVED_TEMPORARILY
+        && overwrite != NGX_HTTP_SEE_OTHER
+        && overwrite != NGX_HTTP_TEMPORARY_REDIRECT)
     {
-        r->err_status = overwrite;
-
-    } else {
         r->err_status = NGX_HTTP_MOVED_TEMPORARILY;
     }