diff options
author | Igor Sysoev <igor@sysoev.ru> | 2005-10-27 15:46:13 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2005-10-27 15:46:13 +0000 |
commit | 697d1aea0c7b1525beed2911f9f32426280df8f4 (patch) | |
tree | 3c59875442d9a8114785a04003fcc3b7b059dc55 /src/http/ngx_http_variables.c | |
parent | 968b2a868ba7950b7c11c81905eeb5ed87b889f2 (diff) | |
download | nginx-release-0.3.7.tar.gz nginx-release-0.3.7.zip |
nginx-0.3.7-RELEASE importrelease-0.3.7
*) Feature: the "access_log" supports the "buffer=" parameter.
*) Bugfix: nginx could not be built on platforms different from i386,
amd64, sparc, and ppc; the bug had appeared in 0.3.2.
Diffstat (limited to 'src/http/ngx_http_variables.c')
-rw-r--r-- | src/http/ngx_http_variables.c | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c index 3cb3bdf5b..e3954009b 100644 --- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -36,6 +36,8 @@ static ngx_http_variable_value_t * ngx_http_variable_request_method(ngx_http_request_t *r, uintptr_t data); static ngx_http_variable_value_t * ngx_http_variable_remote_user(ngx_http_request_t *r, uintptr_t data); +static ngx_http_variable_value_t * + ngx_http_variable_sent(ngx_http_request_t *r, uintptr_t data); /* @@ -44,8 +46,7 @@ static ngx_http_variable_value_t * * REMOTE_HOST (null), REMOTE_IDENT (null), * SERVER_SOFTWARE * - * Apache SSI: DATE_GMT, DOCUMENT_NAME, LAST_MODIFIED, - * USER_NAME (file owner) + * Apache SSI: DOCUMENT_NAME, LAST_MODIFIED, USER_NAME (file owner) */ static ngx_http_variable_t ngx_http_core_variables[] = { @@ -116,6 +117,10 @@ static ngx_http_variable_t ngx_http_core_variables[] = { { ngx_string("remote_user"), ngx_http_variable_remote_user, 0, 0, 0 }, + { ngx_string("sent"), ngx_http_variable_sent, 0, 0, 0 }, + + { ngx_string("apache_sent"), ngx_http_variable_sent, 1, 0, 0 }, + { ngx_null_string, NULL, 0, 0, 0 } }; @@ -699,6 +704,41 @@ ngx_http_variable_remote_user(ngx_http_request_t *r, uintptr_t data) } +static ngx_http_variable_value_t * +ngx_http_variable_sent(ngx_http_request_t *r, uintptr_t data) +{ + off_t sent; + u_char *p; + ngx_http_variable_value_t *vv; + + vv = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)); + if (vv == NULL) { + return NULL; + } + + sent = r->connection->sent; + + if (data) { + sent -= r->header_size; + + if (sent < 0) { + sent = 0; + } + } + + p = ngx_palloc(r->pool, NGX_OFF_T_LEN); + if (p == NULL) { + return NULL; + } + + vv->value = 0; + vv->text.len = ngx_sprintf(p, "%O", sent) - p; + vv->text.data = p; + + return vv; +} + + ngx_int_t ngx_http_variables_add_core_vars(ngx_conf_t *cf) { |