aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2006-10-02 11:07:36 +0000
committerIgor Sysoev <igor@sysoev.ru>2006-10-02 11:07:36 +0000
commit49c9ea0e262e4f65d47f5cedd5b412d7babf9200 (patch)
tree15b7204d6a618e4c5571c4fa84a43b417bf41a92
parent8fd830adc0a3bcdcf471237e2c4445d15e64face (diff)
downloadnginx-49c9ea0e262e4f65d47f5cedd5b412d7babf9200.tar.gz
nginx-49c9ea0e262e4f65d47f5cedd5b412d7babf9200.zip
$scheme variable
-rw-r--r--src/http/ngx_http_variables.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
index d5fbfc9b7..7dc9cc146 100644
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -36,6 +36,8 @@ static ngx_int_t ngx_http_variable_server_addr(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
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_document_root(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_request_filename(ngx_http_request_t *r,
@@ -122,6 +124,8 @@ static ngx_http_variable_t ngx_http_core_variables[] = {
{ ngx_string("server_protocol"), NULL, ngx_http_variable_request,
offsetof(ngx_http_request_t, http_protocol), 0, 0 },
+ { ngx_string("scheme"), NULL, ngx_http_variable_scheme, 0, 0, 0 },
+
{ ngx_string("request_uri"), NULL, ngx_http_variable_request,
offsetof(ngx_http_request_t, unparsed_uri), 0, 0 },
@@ -772,6 +776,34 @@ ngx_http_variable_server_port(ngx_http_request_t *r,
static ngx_int_t
+ngx_http_variable_scheme(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("https") - 1;
+ v->valid = 1;
+ v->no_cachable = 0;
+ v->not_found = 0;
+ v->data = "https";
+
+ return NGX_OK;
+ }
+
+#endif
+
+ v->len = sizeof("http") - 1;
+ v->valid = 1;
+ v->no_cachable = 0;
+ v->not_found = 0;
+ v->data = "http";
+
+ return NGX_OK;
+}
+
+
+static ngx_int_t
ngx_http_variable_document_root(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data)
{