]> git.kaiwu.me - nginx.git/commitdiff
r1404 merge:
authorIgor Sysoev <igor@sysoev.ru>
Sat, 22 Sep 2007 19:10:53 +0000 (19:10 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Sat, 22 Sep 2007 19:10:53 +0000 (19:10 +0000)
auto redirect lost arguments

src/http/ngx_http_core_module.c

index b2b0f3bca034feec69aa9f8e2a0e44e0a229d45c..c7fa92cebaafabd70696149fd91ffeef9470b151 100644 (file)
@@ -620,6 +620,8 @@ ngx_int_t
 ngx_http_core_find_config_phase(ngx_http_request_t *r,
     ngx_http_phase_handler_t *ph)
 {
+    u_char                    *p;
+    size_t                     len;
     ngx_int_t                  rc;
     ngx_http_core_loc_conf_t  *clcf;
     ngx_http_core_srv_conf_t  *cscf;
@@ -680,7 +682,25 @@ ngx_http_core_find_config_phase(ngx_http_request_t *r,
          * r->headers_out.location->key fields
          */
 
-        r->headers_out.location->value = clcf->name;
+        if (r->args.len == 0) {
+            r->headers_out.location->value = clcf->name;
+
+        } else {
+            len = clcf->name.len + 1 + r->args.len;
+            p = ngx_palloc(r->pool, len);
+
+            if (p == NULL) {
+                ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+                return NGX_OK;
+            }
+
+            r->headers_out.location->value.len = len;
+            r->headers_out.location->value.data = p;
+
+            p = ngx_cpymem(p, clcf->name.data, clcf->name.len);
+            *p++ = '?';
+            ngx_memcpy(p, r->args.data, r->args.len);
+        }
 
         ngx_http_finalize_request(r, NGX_HTTP_MOVED_PERMANENTLY);
         return NGX_OK;