comparison src/http/ngx_http_variables.c @ 690:b5b7eea22fda NGINX_1_3_8

nginx 1.3.8 *) Feature: the "optional_no_ca" parameter of the "ssl_verify_client" directive. Thanks to Mike Kazantsev and Eric O'Connor. *) Feature: the $bytes_sent, $connection, and $connection_requests variables can now be used not only in the "log_format" directive. Thanks to Benjamin Grössing. *) Feature: the "auto" parameter of the "worker_processes" directive. *) Bugfix: "cache file ... has md5 collision" alert. *) Bugfix: in the ngx_http_gunzip_filter_module. *) Bugfix: in the "ssl_stapling" directive.
author Igor Sysoev <http://sysoev.ru>
date Tue, 30 Oct 2012 00:00:00 +0400
parents 981b4c44593b
children 6db6e93f55ee
comparison
equal deleted inserted replaced
689:4d942f0d1703 690:b5b7eea22fda
67 ngx_http_variable_value_t *v, uintptr_t data); 67 ngx_http_variable_value_t *v, uintptr_t data);
68 static ngx_int_t ngx_http_variable_request_method(ngx_http_request_t *r, 68 static ngx_int_t ngx_http_variable_request_method(ngx_http_request_t *r,
69 ngx_http_variable_value_t *v, uintptr_t data); 69 ngx_http_variable_value_t *v, uintptr_t data);
70 static ngx_int_t ngx_http_variable_remote_user(ngx_http_request_t *r, 70 static ngx_int_t ngx_http_variable_remote_user(ngx_http_request_t *r,
71 ngx_http_variable_value_t *v, uintptr_t data); 71 ngx_http_variable_value_t *v, uintptr_t data);
72 static ngx_int_t ngx_http_variable_bytes_sent(ngx_http_request_t *r,
73 ngx_http_variable_value_t *v, uintptr_t data);
72 static ngx_int_t ngx_http_variable_body_bytes_sent(ngx_http_request_t *r, 74 static ngx_int_t ngx_http_variable_body_bytes_sent(ngx_http_request_t *r,
73 ngx_http_variable_value_t *v, uintptr_t data); 75 ngx_http_variable_value_t *v, uintptr_t data);
74 static ngx_int_t ngx_http_variable_request_completion(ngx_http_request_t *r, 76 static ngx_int_t ngx_http_variable_request_completion(ngx_http_request_t *r,
75 ngx_http_variable_value_t *v, uintptr_t data); 77 ngx_http_variable_value_t *v, uintptr_t data);
76 static ngx_int_t ngx_http_variable_request_body(ngx_http_request_t *r, 78 static ngx_int_t ngx_http_variable_request_body(ngx_http_request_t *r,
91 static ngx_int_t ngx_http_variable_sent_connection(ngx_http_request_t *r, 93 static ngx_int_t ngx_http_variable_sent_connection(ngx_http_request_t *r,
92 ngx_http_variable_value_t *v, uintptr_t data); 94 ngx_http_variable_value_t *v, uintptr_t data);
93 static ngx_int_t ngx_http_variable_sent_keep_alive(ngx_http_request_t *r, 95 static ngx_int_t ngx_http_variable_sent_keep_alive(ngx_http_request_t *r,
94 ngx_http_variable_value_t *v, uintptr_t data); 96 ngx_http_variable_value_t *v, uintptr_t data);
95 static ngx_int_t ngx_http_variable_sent_transfer_encoding(ngx_http_request_t *r, 97 static ngx_int_t ngx_http_variable_sent_transfer_encoding(ngx_http_request_t *r,
98 ngx_http_variable_value_t *v, uintptr_t data);
99
100 static ngx_int_t ngx_http_variable_connection(ngx_http_request_t *r,
101 ngx_http_variable_value_t *v, uintptr_t data);
102 static ngx_int_t ngx_http_variable_connection_requests(ngx_http_request_t *r,
96 ngx_http_variable_value_t *v, uintptr_t data); 103 ngx_http_variable_value_t *v, uintptr_t data);
97 104
98 static ngx_int_t ngx_http_variable_nginx_version(ngx_http_request_t *r, 105 static ngx_int_t ngx_http_variable_nginx_version(ngx_http_request_t *r,
99 ngx_http_variable_value_t *v, uintptr_t data); 106 ngx_http_variable_value_t *v, uintptr_t data);
100 static ngx_int_t ngx_http_variable_hostname(ngx_http_request_t *r, 107 static ngx_int_t ngx_http_variable_hostname(ngx_http_request_t *r,
210 ngx_http_variable_request_method, 0, 217 ngx_http_variable_request_method, 0,
211 NGX_HTTP_VAR_NOCACHEABLE, 0 }, 218 NGX_HTTP_VAR_NOCACHEABLE, 0 },
212 219
213 { ngx_string("remote_user"), NULL, ngx_http_variable_remote_user, 0, 0, 0 }, 220 { ngx_string("remote_user"), NULL, ngx_http_variable_remote_user, 0, 0, 0 },
214 221
222 { ngx_string("bytes_sent"), NULL, ngx_http_variable_bytes_sent,
223 0, 0, 0 },
224
215 { ngx_string("body_bytes_sent"), NULL, ngx_http_variable_body_bytes_sent, 225 { ngx_string("body_bytes_sent"), NULL, ngx_http_variable_body_bytes_sent,
216 0, 0, 0 }, 226 0, 0, 0 },
217 227
218 { ngx_string("request_completion"), NULL, 228 { ngx_string("request_completion"), NULL,
219 ngx_http_variable_request_completion, 229 ngx_http_variable_request_completion,
257 267
258 { ngx_string("limit_rate"), ngx_http_variable_request_set_size, 268 { ngx_string("limit_rate"), ngx_http_variable_request_set_size,
259 ngx_http_variable_request_get_size, 269 ngx_http_variable_request_get_size,
260 offsetof(ngx_http_request_t, limit_rate), 270 offsetof(ngx_http_request_t, limit_rate),
261 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 }, 271 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 },
272
273 { ngx_string("connection"), NULL,
274 ngx_http_variable_connection, 0, 0, 0 },
275
276 { ngx_string("connection_requests"), NULL,
277 ngx_http_variable_connection_requests, 0, 0, 0 },
262 278
263 { ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version, 279 { ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version,
264 0, 0, 0 }, 280 0, 0, 0 },
265 281
266 { ngx_string("hostname"), NULL, ngx_http_variable_hostname, 282 { ngx_string("hostname"), NULL, ngx_http_variable_hostname,
1432 return NGX_OK; 1448 return NGX_OK;
1433 } 1449 }
1434 1450
1435 1451
1436 static ngx_int_t 1452 static ngx_int_t
1453 ngx_http_variable_bytes_sent(ngx_http_request_t *r,
1454 ngx_http_variable_value_t *v, uintptr_t data)
1455 {
1456 u_char *p;
1457
1458 p = ngx_pnalloc(r->pool, NGX_OFF_T_LEN);
1459 if (p == NULL) {
1460 return NGX_ERROR;
1461 }
1462
1463 v->len = ngx_sprintf(p, "%O", r->connection->sent) - p;
1464 v->valid = 1;
1465 v->no_cacheable = 0;
1466 v->not_found = 0;
1467 v->data = p;
1468
1469 return NGX_OK;
1470 }
1471
1472
1473 static ngx_int_t
1437 ngx_http_variable_body_bytes_sent(ngx_http_request_t *r, 1474 ngx_http_variable_body_bytes_sent(ngx_http_request_t *r,
1438 ngx_http_variable_value_t *v, uintptr_t data) 1475 ngx_http_variable_value_t *v, uintptr_t data)
1439 { 1476 {
1440 off_t sent; 1477 off_t sent;
1441 u_char *p; 1478 u_char *p;
1780 v->len = r->request_body->temp_file->file.name.len; 1817 v->len = r->request_body->temp_file->file.name.len;
1781 v->valid = 1; 1818 v->valid = 1;
1782 v->no_cacheable = 0; 1819 v->no_cacheable = 0;
1783 v->not_found = 0; 1820 v->not_found = 0;
1784 v->data = r->request_body->temp_file->file.name.data; 1821 v->data = r->request_body->temp_file->file.name.data;
1822
1823 return NGX_OK;
1824 }
1825
1826
1827 static ngx_int_t
1828 ngx_http_variable_connection(ngx_http_request_t *r,
1829 ngx_http_variable_value_t *v, uintptr_t data)
1830 {
1831 u_char *p;
1832
1833 p = ngx_pnalloc(r->pool, NGX_ATOMIC_T_LEN);
1834 if (p == NULL) {
1835 return NGX_ERROR;
1836 }
1837
1838 v->len = ngx_sprintf(p, "%uA", r->connection->number) - p;
1839 v->valid = 1;
1840 v->no_cacheable = 0;
1841 v->not_found = 0;
1842 v->data = p;
1843
1844 return NGX_OK;
1845 }
1846
1847
1848 static ngx_int_t
1849 ngx_http_variable_connection_requests(ngx_http_request_t *r,
1850 ngx_http_variable_value_t *v, uintptr_t data)
1851 {
1852 u_char *p;
1853
1854 p = ngx_pnalloc(r->pool, NGX_INT_T_LEN);
1855 if (p == NULL) {
1856 return NGX_ERROR;
1857 }
1858
1859 v->len = ngx_sprintf(p, "%ui", r->connection->requests) - p;
1860 v->valid = 1;
1861 v->no_cacheable = 0;
1862 v->not_found = 0;
1863 v->data = p;
1785 1864
1786 return NGX_OK; 1865 return NGX_OK;
1787 } 1866 }
1788 1867
1789 1868