aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_parse.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2008-12-22 12:02:05 +0000
committerIgor Sysoev <igor@sysoev.ru>2008-12-22 12:02:05 +0000
commit84d17bba650167380268ee0f86c6789a04a02426 (patch)
tree13b6bf1466ef1ac3112c2a4d028d34c31385eaac /src/http/ngx_http_parse.c
parented9b6d8962c6b7cf0546d0b2d69f34c879395757 (diff)
downloadnginx-84d17bba650167380268ee0f86c6789a04a02426.tar.gz
nginx-84d17bba650167380268ee0f86c6789a04a02426.zip
ngx_http_arg()
Diffstat (limited to 'src/http/ngx_http_parse.c')
-rw-r--r--src/http/ngx_http_parse.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
index b08d5eaa7..f31df7b1f 100644
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -1481,3 +1481,45 @@ ngx_http_parse_multi_header_lines(ngx_array_t *headers, ngx_str_t *name,
return NGX_DECLINED;
}
+
+
+ngx_int_t
+ngx_http_arg(ngx_http_request_t *r, u_char *name, size_t len, ngx_str_t *value)
+{
+ u_char *p;
+
+ if (r->args.len == 0) {
+ return NGX_DECLINED;
+ }
+
+ for (p = r->args.data; *p && *p != ' '; p++) {
+
+ /*
+ * although r->args.data is not null-terminated by itself,
+ * however, there is null in the end of request line
+ */
+
+ p = ngx_strcasestrn(p, (char *) name, len - 1);
+
+ if (p == NULL) {
+ return NGX_DECLINED;
+ }
+
+ if ((p == r->args.data || *(p - 1) == '&') && *(p + len) == '=') {
+
+ value->data = p + len + 1;
+
+ p = (u_char *) ngx_strchr(p, '&');
+
+ if (p == NULL) {
+ p = r->args.data + r->args.len;
+ }
+
+ value->len = p - value->data;
+
+ return NGX_OK;
+ }
+ }
+
+ return NGX_DECLINED;
+}