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

ngx_http_arg()
author Igor Sysoev <igor@sysoev.ru>
date Mon, 22 Dec 2008 12:02:05 +0000
parents 4fee4ebbfb0b
children 51b1097dbb67
comparison
equal deleted inserted replaced
2414:cc13ff6d5c07 2415:d311b7f6a403
770 ngx_http_variable_argument(ngx_http_request_t *r, ngx_http_variable_value_t *v, 770 ngx_http_variable_argument(ngx_http_request_t *r, ngx_http_variable_value_t *v,
771 uintptr_t data) 771 uintptr_t data)
772 { 772 {
773 ngx_str_t *name = (ngx_str_t *) data; 773 ngx_str_t *name = (ngx_str_t *) data;
774 774
775 u_char *p, *arg; 775 u_char *arg;
776 size_t len; 776 size_t len;
777 777 ngx_str_t value;
778 if (r->args.len == 0) { 778
779 len = name->len - (sizeof("arg_") - 1);
780 arg = name->data + sizeof("arg_") - 1;
781
782 if (ngx_http_arg(r, arg, len, &value) != NGX_OK) {
779 v->not_found = 1; 783 v->not_found = 1;
780 return NGX_OK; 784 return NGX_OK;
781 } 785 }
782 786
783 len = name->len - 1 - (sizeof("arg_") - 1); 787 v->data = value.data;
784 arg = name->data + sizeof("arg_") - 1; 788 v->len = value.len;
785 789 v->valid = 1;
786 for (p = r->args.data; *p && *p != ' '; p++) { 790 v->no_cacheable = 0;
787 791 v->not_found = 0;
788 /*
789 * although r->args.data is not null-terminated by itself,
790 * however, there is null in the end of request line
791 */
792
793 p = ngx_strcasestrn(p, (char *) arg, len);
794
795 if (p == NULL) {
796 v->not_found = 1;
797 return NGX_OK;
798 }
799
800 if ((p == r->args.data || *(p - 1) == '&') && *(p + len + 1) == '=') {
801
802 v->data = p + len + 2;
803
804 p = (u_char *) ngx_strchr(p, '&');
805
806 if (p == NULL) {
807 p = r->args.data + r->args.len;
808 }
809
810 v->len = p - v->data;
811 v->valid = 1;
812 v->no_cacheable = 0;
813 v->not_found = 0;
814
815 return NGX_OK;
816 }
817 }
818
819 v->not_found = 1;
820 792
821 return NGX_OK; 793 return NGX_OK;
822 } 794 }
823 795
824 796