comparison src/http/ngx_http_variables.c @ 540:c04fa65fe604 NGINX_0_8_22

nginx 0.8.22 *) Feature: the "proxy_bind", "fastcgi_bind", and "memcached_bind" directives. *) Feature: the "access" and the "deny" directives support IPv6. *) Feature: the "set_real_ip_from" directive supports IPv6 addresses in request headers. *) Feature: the "unix:" parameter of the "set_real_ip_from" directive. *) Bugfix: nginx did not delete unix domain socket after configuration testing. *) Bugfix: nginx deleted unix domain socket while online upgrade. *) Bugfix: the "!-x" operator did not work. Thanks to Maxim Dounin. *) Bugfix: a segmentation fault might occur in a worker process, if limit_rate was used in HTTPS server. Thanks to Maxim Dounin. *) Bugfix: a segmentation fault might occur in a worker process while $limit_rate logging. Thanks to Maxim Dounin. *) Bugfix: a segmentation fault might occur in a worker process, if there was no "listen" directive in "server" block; the bug had appeared in 0.8.21.
author Igor Sysoev <http://sysoev.ru>
date Tue, 03 Nov 2009 00:00:00 +0300
parents 005a70f9573b
children e19e5f542878
comparison
equal deleted inserted replaced
539:c88014f74832 540:c04fa65fe604
11 11
12 12
13 static ngx_int_t ngx_http_variable_request(ngx_http_request_t *r, 13 static ngx_int_t ngx_http_variable_request(ngx_http_request_t *r,
14 ngx_http_variable_value_t *v, uintptr_t data); 14 ngx_http_variable_value_t *v, uintptr_t data);
15 static void ngx_http_variable_request_set(ngx_http_request_t *r, 15 static void ngx_http_variable_request_set(ngx_http_request_t *r,
16 ngx_http_variable_value_t *v, uintptr_t data);
17 static ngx_int_t ngx_http_variable_request_get_size(ngx_http_request_t *r,
16 ngx_http_variable_value_t *v, uintptr_t data); 18 ngx_http_variable_value_t *v, uintptr_t data);
17 static void ngx_http_variable_request_set_size(ngx_http_request_t *r, 19 static void ngx_http_variable_request_set_size(ngx_http_request_t *r,
18 ngx_http_variable_value_t *v, uintptr_t data); 20 ngx_http_variable_value_t *v, uintptr_t data);
19 static ngx_int_t ngx_http_variable_header(ngx_http_request_t *r, 21 static ngx_int_t ngx_http_variable_header(ngx_http_request_t *r,
20 ngx_http_variable_value_t *v, uintptr_t data); 22 ngx_http_variable_value_t *v, uintptr_t data);
236 238
237 { ngx_string("sent_http_cache_control"), NULL, ngx_http_variable_headers, 239 { ngx_string("sent_http_cache_control"), NULL, ngx_http_variable_headers,
238 offsetof(ngx_http_request_t, headers_out.cache_control), 0, 0 }, 240 offsetof(ngx_http_request_t, headers_out.cache_control), 0, 0 },
239 241
240 { ngx_string("limit_rate"), ngx_http_variable_request_set_size, 242 { ngx_string("limit_rate"), ngx_http_variable_request_set_size,
241 ngx_http_variable_request, 243 ngx_http_variable_request_get_size,
242 offsetof(ngx_http_request_t, limit_rate), 244 offsetof(ngx_http_request_t, limit_rate),
243 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 }, 245 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 },
244 246
245 { ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version, 247 { ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version,
246 0, 0, 0 }, 248 0, 0, 0 },
566 s->len = v->len; 568 s->len = v->len;
567 s->data = v->data; 569 s->data = v->data;
568 } 570 }
569 571
570 572
573 static ngx_int_t
574 ngx_http_variable_request_get_size(ngx_http_request_t *r,
575 ngx_http_variable_value_t *v, uintptr_t data)
576 {
577 size_t *sp;
578
579 sp = (size_t *) ((char *) r + data);
580
581 v->data = ngx_pnalloc(r->pool, NGX_SIZE_T_LEN);
582 if (v->data == NULL) {
583 return NGX_ERROR;
584 }
585
586 v->len = ngx_sprintf(v->data, "%uz", *sp) - v->data;
587 v->valid = 1;
588 v->no_cacheable = 0;
589 v->not_found = 0;
590
591 return NGX_OK;
592 }
593
594
571 static void 595 static void
572 ngx_http_variable_request_set_size(ngx_http_request_t *r, 596 ngx_http_variable_request_set_size(ngx_http_request_t *r,
573 ngx_http_variable_value_t *v, uintptr_t data) 597 ngx_http_variable_value_t *v, uintptr_t data)
574 { 598 {
575 ssize_t s, *sp; 599 ssize_t s, *sp;
885 909
886 v->len = sizeof(struct in6_addr); 910 v->len = sizeof(struct in6_addr);
887 v->valid = 1; 911 v->valid = 1;
888 v->no_cacheable = 0; 912 v->no_cacheable = 0;
889 v->not_found = 0; 913 v->not_found = 0;
890 v->data = (u_char *) &sin6->sin6_addr; 914 v->data = sin6->sin6_addr.s6_addr;
891 915
892 break; 916 break;
893 #endif 917 #endif
894 918
895 default: /* AF_INET */ 919 default: /* AF_INET */