diff src/http/ngx_http_special_response.c @ 222:dd6c66b5b0e2 NGINX_0_3_58

nginx 0.3.58 *) Feature: the "error_page" directive supports the variables. *) Change: now the procfs interface instead of sysctl is used on Linux. *) Change: now the "Content-Type" header line is inherited from first response when the "X-Accel-Redirect" was used. *) Bugfix: the "error_page" directive did not redirect the 413 error. *) Bugfix: the trailing "?" did not remove old arguments if no new arguments were added to a rewritten URI. *) Bugfix: nginx could not run on 64-bit FreeBSD 7.0-CURRENT.
author Igor Sysoev <http://sysoev.ru>
date Mon, 14 Aug 2006 00:00:00 +0400
parents 8759b346e431
children 9909a161eb28
line wrap: on
line diff
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -295,8 +295,9 @@ ngx_int_t
 ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
 {
     ngx_int_t                  rc;
+    ngx_buf_t                 *b;
+    ngx_str_t                 *uri;
     ngx_uint_t                 i, err, msie_padding;
-    ngx_buf_t                 *b;
     ngx_chain_t               *out, *cl;
     ngx_http_err_page_t       *err_page;
     ngx_http_core_loc_conf_t  *clcf;
@@ -349,9 +350,20 @@ ngx_http_special_response_handler(ngx_ht
 
                 r->method = NGX_HTTP_GET;
 
-                if (err_page[i].uri.data[0] == '/') {
-                    return ngx_http_internal_redirect(r, &err_page[i].uri,
-                                                      NULL);
+                uri = &err_page[i].uri;
+
+                if (err_page[i].uri_lengths) {
+                    if (ngx_http_script_run(r, uri,
+                                            err_page[i].uri_lengths->elts, 0,
+                                            err_page[i].uri_values->elts)
+                        == NULL)
+                    {
+                        return NGX_ERROR;
+                    }
+                }
+
+                if (uri->data[0] == '/') {
+                    return ngx_http_internal_redirect(r, uri, NULL);
                 }
 
                 r->headers_out.location =
@@ -364,10 +376,10 @@ ngx_http_special_response_handler(ngx_ht
                     r->headers_out.location->hash = 1;
                     r->headers_out.location->key.len = sizeof("Location") - 1;
                     r->headers_out.location->key.data = (u_char *) "Location";
-                    r->headers_out.location->value = err_page[i].uri;
+                    r->headers_out.location->value = *uri;
 
                 } else {
-                    error = NGX_HTTP_INTERNAL_SERVER_ERROR;
+                    return NGX_ERROR;
                 }
             }
         }