comparison src/http/ngx_http_parse.c @ 2415:d311b7f6a403

ngx_http_arg()
author Igor Sysoev <igor@sysoev.ru>
date Mon, 22 Dec 2008 12:02:05 +0000
parents 8c17cfe63d2c
children c7bdd722532f
comparison
equal deleted inserted replaced
2414:cc13ff6d5c07 2415:d311b7f6a403
1479 } 1479 }
1480 } 1480 }
1481 1481
1482 return NGX_DECLINED; 1482 return NGX_DECLINED;
1483 } 1483 }
1484
1485
1486 ngx_int_t
1487 ngx_http_arg(ngx_http_request_t *r, u_char *name, size_t len, ngx_str_t *value)
1488 {
1489 u_char *p;
1490
1491 if (r->args.len == 0) {
1492 return NGX_DECLINED;
1493 }
1494
1495 for (p = r->args.data; *p && *p != ' '; p++) {
1496
1497 /*
1498 * although r->args.data is not null-terminated by itself,
1499 * however, there is null in the end of request line
1500 */
1501
1502 p = ngx_strcasestrn(p, (char *) name, len - 1);
1503
1504 if (p == NULL) {
1505 return NGX_DECLINED;
1506 }
1507
1508 if ((p == r->args.data || *(p - 1) == '&') && *(p + len) == '=') {
1509
1510 value->data = p + len + 1;
1511
1512 p = (u_char *) ngx_strchr(p, '&');
1513
1514 if (p == NULL) {
1515 p = r->args.data + r->args.len;
1516 }
1517
1518 value->len = p - value->data;
1519
1520 return NGX_OK;
1521 }
1522 }
1523
1524 return NGX_DECLINED;
1525 }