]> git.kaiwu.me - nginx.git/commitdiff
ngx_http_split_args()
authorIgor Sysoev <igor@sysoev.ru>
Thu, 19 Mar 2009 13:41:29 +0000 (13:41 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Thu, 19 Mar 2009 13:41:29 +0000 (13:41 +0000)
src/http/ngx_http.h
src/http/ngx_http_parse.c

index cac2a9c3ce2849eb8354bcbe17b4b1b871e9496a..3cc869a753c16eac46d4b44edb3f69532964acda 100644 (file)
@@ -78,6 +78,8 @@ ngx_int_t ngx_http_parse_multi_header_lines(ngx_array_t *headers,
     ngx_str_t *name, ngx_str_t *value);
 ngx_int_t ngx_http_arg(ngx_http_request_t *r, u_char *name, size_t len,
     ngx_str_t *value);
+void ngx_http_split_args(ngx_http_request_t *r, ngx_str_t *uri,
+    ngx_str_t *args);
 
 
 ngx_int_t ngx_http_find_server_conf(ngx_http_request_t *r);
index f31df7b1f0e63303195a5be8982bd023dc0d7a57..318a33b570bbb315eb2c77e418d2521c24867802 100644 (file)
@@ -1523,3 +1523,37 @@ ngx_http_arg(ngx_http_request_t *r, u_char *name, size_t len, ngx_str_t *value)
 
     return NGX_DECLINED;
 }
+
+
+void
+ngx_http_split_args(ngx_http_request_t *r, ngx_str_t *uri, ngx_str_t *args)
+{
+    u_char  ch, *p, *last;
+
+    p = uri->data;
+
+    last = p + uri->len;
+
+    while (p < last) {
+
+       ch = *p++;
+
+       if (ch == '?') {
+           args->len = last - p;
+           args->data = p;
+
+           uri->len = p - 1 - uri->data;
+
+           if (ngx_strlchr(p, last, '\0') != NULL) {
+               r->zero_in_uri = 1;
+           }
+
+           return;
+       }
+
+       if (ch == '\0') {
+           r->zero_in_uri = 1;
+           continue;
+       }
+    }
+}