]> git.kaiwu.me - nginx.git/commitdiff
Upstream: support named location for X-Accel-Redirect.
authorToshikuni Fukaya <toshikuni-fukaya@cybozu.co.jp>
Tue, 4 Nov 2014 10:56:23 +0000 (19:56 +0900)
committerToshikuni Fukaya <toshikuni-fukaya@cybozu.co.jp>
Tue, 4 Nov 2014 10:56:23 +0000 (19:56 +0900)
src/http/ngx_http_upstream.c

index 3e8ce09e1a7b89d9b369898ea22fcf23cb2b17b2..f343d046384dffab82ecb10f7cc0ab4268a08be4 100644 (file)
@@ -2218,19 +2218,26 @@ ngx_http_upstream_process_headers(ngx_http_request_t *r, ngx_http_upstream_t *u)
         }
 
         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 (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;
+            }
 
-        if (r->method != NGX_HTTP_HEAD) {
-            r->method = NGX_HTTP_GET;
+            ngx_http_internal_redirect(r, &uri, &args);
         }
 
-        ngx_http_internal_redirect(r, &uri, &args);
         ngx_http_finalize_request(r, NGX_DONE);
         return NGX_DONE;
     }