diff options
author | Valentin Bartenev <vbart@nginx.com> | 2011-12-09 14:38:11 +0000 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2011-12-09 14:38:11 +0000 |
commit | 247332a1e269f3015eaaeaac6541aa06170b4430 (patch) | |
tree | ac01410f6e00204789c7fa311b08420b5ecf11b6 /src/http/ngx_http_variables.c | |
parent | df54c36d90ff0bdebe7adba5de582072f9af69f8 (diff) | |
download | nginx-247332a1e269f3015eaaeaac6541aa06170b4430.tar.gz nginx-247332a1e269f3015eaaeaac6541aa06170b4430.zip |
Added the $https variable.
Diffstat (limited to 'src/http/ngx_http_variables.c')
-rw-r--r-- | src/http/ngx_http_variables.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c index 4afd88405..16c42faa7 100644 --- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -48,6 +48,8 @@ static ngx_int_t ngx_http_variable_server_port(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_scheme(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); +static ngx_int_t ngx_http_variable_https(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_is_args(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_document_root(ngx_http_request_t *r, @@ -157,6 +159,8 @@ static ngx_http_variable_t ngx_http_core_variables[] = { { ngx_string("scheme"), NULL, ngx_http_variable_scheme, 0, 0, 0 }, + { ngx_string("https"), NULL, ngx_http_variable_https, 0, 0, 0 }, + { ngx_string("request_uri"), NULL, ngx_http_variable_request, offsetof(ngx_http_request_t, unparsed_uri), 0, 0 }, @@ -1091,6 +1095,30 @@ ngx_http_variable_scheme(ngx_http_request_t *r, static ngx_int_t +ngx_http_variable_https(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data) +{ +#if (NGX_HTTP_SSL) + + if (r->connection->ssl) { + v->len = sizeof("on") - 1; + v->valid = 1; + v->no_cacheable = 0; + v->not_found = 0; + v->data = (u_char *) "on"; + + return NGX_OK; + } + +#endif + + *v = ngx_http_variable_null_value; + + return NGX_OK; +} + + +static ngx_int_t ngx_http_variable_is_args(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) { |