diff options
author | Igor Sysoev <igor@sysoev.ru> | 2009-03-19 13:41:29 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2009-03-19 13:41:29 +0000 |
commit | 2c7cb55ac1e94a0c165835933dcbe86d3904f623 (patch) | |
tree | 07aabfbd5751936fefeec474415b88c4855dc7ce | |
parent | 165b3c001cff1ec195725599ce0636f48e974bde (diff) | |
download | nginx-2c7cb55ac1e94a0c165835933dcbe86d3904f623.tar.gz |
ngx_http_split_args()
-rw-r--r-- | src/http/ngx_http.h | 2 | ||||
-rw-r--r-- | src/http/ngx_http_parse.c | 34 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h index cac2a9c3c..3cc869a75 100644 --- a/src/http/ngx_http.h +++ b/src/http/ngx_http.h @@ -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); diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c index f31df7b1f..318a33b57 100644 --- a/src/http/ngx_http_parse.c +++ b/src/http/ngx_http_parse.c @@ -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; + } + } +} |