diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2012-10-03 15:25:36 +0000 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2012-10-03 15:25:36 +0000 |
commit | 82989420adcf0cb4e0f00e5f689cb59554e4c24c (patch) | |
tree | 333da22cc619624773b02801e637e5b078b3f531 /src | |
parent | a707811a31455979744e0c456882dd0fa2e9e139 (diff) | |
download | nginx-82989420adcf0cb4e0f00e5f689cb59554e4c24c.tar.gz nginx-82989420adcf0cb4e0f00e5f689cb59554e4c24c.zip |
Variable $bytes_sent.
It replicates variable $bytes_sent as previously available in log module
only.
Patch by Benjamin Grössing (with minor changes).
Diffstat (limited to 'src')
-rw-r--r-- | src/http/ngx_http_variables.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c index f34a6d9a3..e513279e9 100644 --- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -69,6 +69,8 @@ static ngx_int_t ngx_http_variable_request_method(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_remote_user(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); +static ngx_int_t ngx_http_variable_bytes_sent(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_body_bytes_sent(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_request_completion(ngx_http_request_t *r, @@ -212,6 +214,9 @@ static ngx_http_variable_t ngx_http_core_variables[] = { { ngx_string("remote_user"), NULL, ngx_http_variable_remote_user, 0, 0, 0 }, + { ngx_string("bytes_sent"), NULL, ngx_http_variable_bytes_sent, + 0, 0, 0 }, + { ngx_string("body_bytes_sent"), NULL, ngx_http_variable_body_bytes_sent, 0, 0, 0 }, @@ -1434,6 +1439,27 @@ ngx_http_variable_remote_user(ngx_http_request_t *r, static ngx_int_t +ngx_http_variable_bytes_sent(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data) +{ + u_char *p; + + p = ngx_pnalloc(r->pool, NGX_OFF_T_LEN); + if (p == NULL) { + return NGX_ERROR; + } + + v->len = ngx_sprintf(p, "%O", r->connection->sent) - p; + v->valid = 1; + v->no_cacheable = 0; + v->not_found = 0; + v->data = p; + + return NGX_OK; +} + + +static ngx_int_t ngx_http_variable_body_bytes_sent(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) { |