Mercurial > hg > nginx-quic
comparison src/http/ngx_http_variables.c @ 4893:e89bd9896fea
Variables $connection and $connection_requests.
Log module counterparts are removed as they aren't used often and
there is no need to preserve them for efficiency.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 29 Oct 2012 17:17:59 +0000 |
parents | b7f6f097d95e |
children | 002f2c783d7c |
comparison
equal
deleted
inserted
replaced
4892:063ac68d89dc | 4893:e89bd9896fea |
---|---|
93 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, |
94 ngx_http_variable_value_t *v, uintptr_t data); | 94 ngx_http_variable_value_t *v, uintptr_t data); |
95 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, |
96 ngx_http_variable_value_t *v, uintptr_t data); | 96 ngx_http_variable_value_t *v, uintptr_t data); |
97 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, | |
98 ngx_http_variable_value_t *v, uintptr_t data); | 103 ngx_http_variable_value_t *v, uintptr_t data); |
99 | 104 |
100 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, |
101 ngx_http_variable_value_t *v, uintptr_t data); | 106 ngx_http_variable_value_t *v, uintptr_t data); |
102 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, |
263 { ngx_string("limit_rate"), ngx_http_variable_request_set_size, | 268 { ngx_string("limit_rate"), ngx_http_variable_request_set_size, |
264 ngx_http_variable_request_get_size, | 269 ngx_http_variable_request_get_size, |
265 offsetof(ngx_http_request_t, limit_rate), | 270 offsetof(ngx_http_request_t, limit_rate), |
266 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 }, | 271 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
267 | 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 }, | |
278 | |
268 { ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version, | 279 { ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version, |
269 0, 0, 0 }, | 280 0, 0, 0 }, |
270 | 281 |
271 { ngx_string("hostname"), NULL, ngx_http_variable_hostname, | 282 { ngx_string("hostname"), NULL, ngx_http_variable_hostname, |
272 0, 0, 0 }, | 283 0, 0, 0 }, |
1806 v->len = r->request_body->temp_file->file.name.len; | 1817 v->len = r->request_body->temp_file->file.name.len; |
1807 v->valid = 1; | 1818 v->valid = 1; |
1808 v->no_cacheable = 0; | 1819 v->no_cacheable = 0; |
1809 v->not_found = 0; | 1820 v->not_found = 0; |
1810 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; | |
1811 | 1864 |
1812 return NGX_OK; | 1865 return NGX_OK; |
1813 } | 1866 } |
1814 | 1867 |
1815 | 1868 |