[nginx] Upstream: support named location for X-Accel-Redirect.

Maxim Dounin mdounin at mdounin.ru
Tue Nov 11 14:02:29 UTC 2014


details:   http://hg.nginx.org/nginx/rev/7d7eac6e31df
branches:  
changeset: 5901:7d7eac6e31df
user:      Toshikuni Fukaya <toshikuni-fukaya at cybozu.co.jp>
date:      Tue Nov 04 19:56:23 2014 +0900
description:
Upstream: support named location for X-Accel-Redirect.

diffstat:

 src/http/ngx_http_upstream.c |  33 ++++++++++++++++++++-------------
 1 files changed, 20 insertions(+), 13 deletions(-)

diffs (43 lines):

diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -2218,19 +2218,26 @@ ngx_http_upstream_process_headers(ngx_ht
         }
 
         uri = u->headers_in.x_accel_redirect->value;
-        ngx_str_null(&args);
-        flags = NGX_HTTP_LOG_UNSAFE;
-
-        if (ngx_http_parse_unsafe_uri(r, &uri, &args, &flags) != NGX_OK) {
-            ngx_http_finalize_request(r, NGX_HTTP_NOT_FOUND);
-            return NGX_DONE;
-        }
-
-        if (r->method != NGX_HTTP_HEAD) {
-            r->method = NGX_HTTP_GET;
-        }
-
-        ngx_http_internal_redirect(r, &uri, &args);
+
+        if (uri.data[0] == '@') {
+            ngx_http_named_location(r, &uri);
+
+        } else {
+            ngx_str_null(&args);
+            flags = NGX_HTTP_LOG_UNSAFE;
+
+            if (ngx_http_parse_unsafe_uri(r, &uri, &args, &flags) != NGX_OK) {
+                ngx_http_finalize_request(r, NGX_HTTP_NOT_FOUND);
+                return NGX_DONE;
+            }
+
+            if (r->method != NGX_HTTP_HEAD) {
+                r->method = NGX_HTTP_GET;
+            }
+
+            ngx_http_internal_redirect(r, &uri, &args);
+        }
+
         ngx_http_finalize_request(r, NGX_DONE);
         return NGX_DONE;
     }



More information about the nginx-devel mailing list