Mercurial > hg > nginx-vendor-1-0
diff src/http/ngx_http_variables.c @ 238:a528ae0fe909 NGINX_0_4_4
nginx 0.4.4
*) Feature: the $scheme variable.
*) Feature: the "expires" directive supports the "max" parameter.
*) Feature: the "include" directive supports the "*" mask.
Thanks to Jonathan Dance.
*) Bugfix: the "return" directive always overrode the "error_page"
response code redirected by the "error_page" directive.
*) Bugfix: a segmentation fault occurred if zero-length body was in PUT
method.
*) Bugfix: the redirect was changed incorrectly if the variables were
used in the "proxy_redirect" directive.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 02 Oct 2006 00:00:00 +0400 |
parents | 559bc7ec214e |
children | ff906029dd40 |
line wrap: on
line diff
--- 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_serve 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_cor { 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_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 = (u_char *) "https"; + + return NGX_OK; + } + +#endif + + v->len = sizeof("http") - 1; + v->valid = 1; + v->no_cachable = 0; + v->not_found = 0; + v->data = (u_char *) "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) {