aboutsummaryrefslogtreecommitdiff
path: root/src/stream/ngx_stream_variables.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2016-08-11 20:22:23 +0300
committerRoman Arutyunyan <arut@nginx.com>2016-08-11 20:22:23 +0300
commitbe6024f9b72b6d012d52f1ae1c7605a6c4c165da (patch)
tree8837006f7937f59a17adc65f2f5381ad6a4ba5d2 /src/stream/ngx_stream_variables.c
parentea9a1d745b5db26cac2d4b6e231ca6c4af0b4e5a (diff)
downloadnginx-be6024f9b72b6d012d52f1ae1c7605a6c4c165da.tar.gz
nginx-be6024f9b72b6d012d52f1ae1c7605a6c4c165da.zip
Stream: the $status variable.
The stream session status is one of the following: 200 - normal completion 403 - access forbidden 500 - internal server error 502 - bad gateway 503 - limit conn
Diffstat (limited to 'src/stream/ngx_stream_variables.c')
-rw-r--r--src/stream/ngx_stream_variables.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/stream/ngx_stream_variables.c b/src/stream/ngx_stream_variables.c
index f67d74d52..5fa3ec992 100644
--- a/src/stream/ngx_stream_variables.c
+++ b/src/stream/ngx_stream_variables.c
@@ -25,6 +25,8 @@ 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_session_time(ngx_stream_session_t *s,
ngx_stream_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_stream_variable_status(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);
@@ -70,6 +72,9 @@ static ngx_stream_variable_t ngx_stream_core_variables[] = {
{ ngx_string("session_time"), NULL, ngx_stream_variable_session_time,
0, NGX_STREAM_VAR_NOCACHEABLE, 0 },
+ { ngx_string("status"), NULL, ngx_stream_variable_status,
+ 0, NGX_STREAM_VAR_NOCACHEABLE, 0 },
+
{ ngx_string("connection"), NULL,
ngx_stream_variable_connection, 0, 0, 0 },
@@ -530,6 +535,24 @@ ngx_stream_variable_session_time(ngx_stream_session_t *s,
static ngx_int_t
+ngx_stream_variable_status(ngx_stream_session_t *s,
+ ngx_stream_variable_value_t *v, uintptr_t data)
+{
+ v->data = ngx_pnalloc(s->connection->pool, NGX_INT_T_LEN);
+ if (v->data == NULL) {
+ return NGX_ERROR;
+ }
+
+ v->len = ngx_sprintf(v->data, "%03ui", s->status) - v->data;
+ v->valid = 1;
+ v->no_cacheable = 0;
+ v->not_found = 0;
+
+ return NGX_OK;
+}
+
+
+static ngx_int_t
ngx_stream_variable_connection(ngx_stream_session_t *s,
ngx_stream_variable_value_t *v, uintptr_t data)
{