]> git.kaiwu.me - nginx.git/commitdiff
args support in static error_page
authorIgor Sysoev <igor@sysoev.ru>
Tue, 29 Apr 2008 10:06:43 +0000 (10:06 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Tue, 29 Apr 2008 10:06:43 +0000 (10:06 +0000)
src/http/ngx_http_core_module.c
src/http/ngx_http_core_module.h
src/http/ngx_http_special_response.c

index 5eed3b1e18048d82b4aef0ae4390b222322d0772..f57db362247498e663c11140513d8495e37afdf5 100644 (file)
@@ -3471,6 +3471,7 @@ ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 {
     ngx_http_core_loc_conf_t *lcf = conf;
 
+    u_char                     *args;
     ngx_int_t                   overwrite;
     ngx_str_t                  *value, uri;
     ngx_uint_t                  i, n, nvar;
@@ -3539,6 +3540,8 @@ ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
         }
     }
 
+    args = (u_char *) ngx_strchr(uri.data, '?');
+
     for (i = 1; i < cf->args->nelts - n; i++) {
         err = ngx_array_push(lcf->error_pages);
         if (err == NULL) {
@@ -3577,7 +3580,19 @@ ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
             }
         }
 
-        err->uri = uri;
+        if (args) {
+            err->uri.len = args - uri.data;
+            err->uri.data = uri.data;
+            args++;
+            err->args.len = (uri.data + uri.len) - args;
+            err->args.data = args;
+
+        } else {
+            err->uri = uri;
+            err->args.len = 0;
+            err->args.data = NULL;
+        }
+
         err->uri_lengths = uri_lengths;
         err->uri_values = uri_values;
     }
index e11d829417330c137b6ac8c53ffd6c17940b27ba..9a9f97bdd2f45416f8ad398427f2a720f23f2fab 100644 (file)
@@ -225,6 +225,7 @@ typedef struct {
     ngx_int_t                  status;
     ngx_int_t                  overwrite;
     ngx_str_t                  uri;
+    ngx_str_t                  args;
     ngx_array_t               *uri_lengths;
     ngx_array_t               *uri_values;
 } ngx_http_err_page_t;
index 741a9b1d459c4e13e8254ec48efb8981fa373b6d..306944b617520c65e00d0856f6a124c0d08e3dd8 100644 (file)
@@ -441,8 +441,6 @@ ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page)
 
     r->zero_in_uri = 0;
 
-    args = NULL;
-
     if (err_page->uri_lengths) {
         if (ngx_http_script_run(r, &u, err_page->uri_lengths->elts, 0,
                                 err_page->uri_values->elts)
@@ -453,6 +451,7 @@ ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page)
 
         p = u.data;
         uri = &u;
+        args = NULL;
 
         if (*p == '/') {
 
@@ -488,6 +487,7 @@ ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page)
 
     } else {
         uri = &err_page->uri;
+        args = &err_page->args;
     }
 
     if (uri->data[0] == '/') {