comparison src/http/ngx_http_variables.c @ 420:ad0a34a8efa6 NGINX_0_7_22

nginx 0.7.22 *) Feature: the "none" parameter in the "smtp_auth" directive. Thanks to Maxim Dounin. *) Feature: the "$cookie_..." variables. *) Bugfix: the "directio" directive did not work in XFS filesystem. *) Bugfix: the resolver did not understand big DNS responses. Thanks to Zyb.
author Igor Sysoev <http://sysoev.ru>
date Thu, 20 Nov 2008 00:00:00 +0300
parents b246022ef454
children 88d3e895bdf9
comparison
equal deleted inserted replaced
419:b986babf3f57 420:ad0a34a8efa6
486 } 486 }
487 487
488 return NULL; 488 return NULL;
489 } 489 }
490 490
491 if (ngx_strncmp(name->data, "cookie_", 7) == 0) {
492
493 if (ngx_http_variable_argument(r, vv, (uintptr_t) name) == NGX_OK) {
494 return vv;
495 }
496
497 return NULL;
498 }
499
491 if (ngx_strncmp(name->data, "arg_", 4) == 0) { 500 if (ngx_strncmp(name->data, "arg_", 4) == 0) {
492 501
493 if (ngx_http_variable_argument(r, vv, (uintptr_t) name) == NGX_OK) { 502 if (ngx_http_variable_argument(r, vv, (uintptr_t) name) == NGX_OK) {
494 return vv; 503 return vv;
495 } 504 }
720 return NGX_OK; 729 return NGX_OK;
721 } 730 }
722 } 731 }
723 732
724 v->not_found = 1; 733 v->not_found = 1;
734
735 return NGX_OK;
736 }
737
738
739 static ngx_int_t
740 ngx_http_variable_cookie(ngx_http_request_t *r, ngx_http_variable_value_t *v,
741 uintptr_t data)
742 {
743 ngx_str_t *name = (ngx_str_t *) data;
744
745 ngx_str_t cookie, s;
746
747 s.len = name->len - (sizeof("cookie_") - 1);
748 s.data = name->data + sizeof("cookie_") - 1;
749
750 if (ngx_http_parse_multi_header_lines(&r->headers_in.cookies, &s, &cookie)
751 == NGX_DECLINED)
752 {
753 v->not_found = 1;
754 return NGX_OK;
755 }
756
757 v->len = cookie.len;
758 v->valid = 1;
759 v->no_cacheable = 0;
760 v->not_found = 0;
761 v->data = cookie.data;
725 762
726 return NGX_OK; 763 return NGX_OK;
727 } 764 }
728 765
729 766
1542 v[i].flags = NGX_HTTP_VAR_NOCACHEABLE; 1579 v[i].flags = NGX_HTTP_VAR_NOCACHEABLE;
1543 1580
1544 continue; 1581 continue;
1545 } 1582 }
1546 1583
1584 if (ngx_strncmp(v[i].name.data, "cookie_", 7) == 0) {
1585 v[i].get_handler = ngx_http_variable_cookie;
1586 v[i].data = (uintptr_t) &v[i].name;
1587
1588 continue;
1589 }
1590
1547 if (ngx_strncmp(v[i].name.data, "arg_", 4) == 0) { 1591 if (ngx_strncmp(v[i].name.data, "arg_", 4) == 0) {
1548 v[i].get_handler = ngx_http_variable_argument; 1592 v[i].get_handler = ngx_http_variable_argument;
1549 v[i].data = (uintptr_t) &v[i].name; 1593 v[i].data = (uintptr_t) &v[i].name;
1550 1594
1551 continue; 1595 continue;