[nginx] Stream: the $bytes_received variable.
Vladimir Homutov
vl at nginx.com
Fri Aug 26 12:34:55 UTC 2016
details: http://hg.nginx.org/nginx/rev/5e2821c2de46
branches:
changeset: 6668:5e2821c2de46
user: Vladimir Homutov <vl at nginx.com>
date: Fri Aug 26 15:33:02 2016 +0300
description:
Stream: the $bytes_received variable.
The variable keeps the number of bytes received from the client.
diffstat:
src/stream/ngx_stream_variables.c | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diffs (50 lines):
diff -r 33d075b9097d -r 5e2821c2de46 src/stream/ngx_stream_variables.c
--- a/src/stream/ngx_stream_variables.c Mon Aug 15 05:52:04 2016 -0700
+++ b/src/stream/ngx_stream_variables.c Fri Aug 26 15:33:02 2016 +0300
@@ -21,7 +21,7 @@ static ngx_int_t ngx_stream_variable_ser
ngx_stream_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_stream_variable_server_port(ngx_stream_session_t *s,
ngx_stream_variable_value_t *v, uintptr_t data);
-static ngx_int_t ngx_stream_variable_bytes_sent(ngx_stream_session_t *s,
+static ngx_int_t ngx_stream_variable_bytes(ngx_stream_session_t *s,
ngx_stream_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_stream_variable_connection(ngx_stream_session_t *s,
ngx_stream_variable_value_t *v, uintptr_t data);
@@ -57,9 +57,12 @@ static ngx_stream_variable_t ngx_stream
{ ngx_string("server_port"), NULL,
ngx_stream_variable_server_port, 0, 0, 0 },
- { ngx_string("bytes_sent"), NULL, ngx_stream_variable_bytes_sent,
+ { ngx_string("bytes_sent"), NULL, ngx_stream_variable_bytes,
0, 0, 0 },
+ { ngx_string("bytes_received"), NULL, ngx_stream_variable_bytes,
+ 1, 0, 0 },
+
{ ngx_string("connection"), NULL,
ngx_stream_variable_connection, 0, 0, 0 },
@@ -461,7 +464,7 @@ ngx_stream_variable_server_port(ngx_stre
static ngx_int_t
-ngx_stream_variable_bytes_sent(ngx_stream_session_t *s,
+ngx_stream_variable_bytes(ngx_stream_session_t *s,
ngx_stream_variable_value_t *v, uintptr_t data)
{
u_char *p;
@@ -471,7 +474,13 @@ ngx_stream_variable_bytes_sent(ngx_strea
return NGX_ERROR;
}
- v->len = ngx_sprintf(p, "%O", s->connection->sent) - p;
+ if (data == 1) {
+ v->len = ngx_sprintf(p, "%O", s->received) - p;
+
+ } else {
+ v->len = ngx_sprintf(p, "%O", s->connection->sent) - p;
+ }
+
v->valid = 1;
v->no_cacheable = 0;
v->not_found = 0;
More information about the nginx-devel
mailing list