comparison 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
comparison
equal deleted inserted replaced
237:302a8e8b4ae7 238:a528ae0fe909
33 static ngx_int_t ngx_http_variable_remote_port(ngx_http_request_t *r, 33 static ngx_int_t ngx_http_variable_remote_port(ngx_http_request_t *r,
34 ngx_http_variable_value_t *v, uintptr_t data); 34 ngx_http_variable_value_t *v, uintptr_t data);
35 static ngx_int_t ngx_http_variable_server_addr(ngx_http_request_t *r, 35 static ngx_int_t ngx_http_variable_server_addr(ngx_http_request_t *r,
36 ngx_http_variable_value_t *v, uintptr_t data); 36 ngx_http_variable_value_t *v, uintptr_t data);
37 static ngx_int_t ngx_http_variable_server_port(ngx_http_request_t *r, 37 static ngx_int_t ngx_http_variable_server_port(ngx_http_request_t *r,
38 ngx_http_variable_value_t *v, uintptr_t data);
39 static ngx_int_t ngx_http_variable_scheme(ngx_http_request_t *r,
38 ngx_http_variable_value_t *v, uintptr_t data); 40 ngx_http_variable_value_t *v, uintptr_t data);
39 static ngx_int_t ngx_http_variable_document_root(ngx_http_request_t *r, 41 static ngx_int_t ngx_http_variable_document_root(ngx_http_request_t *r,
40 ngx_http_variable_value_t *v, uintptr_t data); 42 ngx_http_variable_value_t *v, uintptr_t data);
41 static ngx_int_t ngx_http_variable_request_filename(ngx_http_request_t *r, 43 static ngx_int_t ngx_http_variable_request_filename(ngx_http_request_t *r,
42 ngx_http_variable_value_t *v, uintptr_t data); 44 ngx_http_variable_value_t *v, uintptr_t data);
120 { ngx_string("server_port"), NULL, ngx_http_variable_server_port, 0, 0, 0 }, 122 { ngx_string("server_port"), NULL, ngx_http_variable_server_port, 0, 0, 0 },
121 123
122 { ngx_string("server_protocol"), NULL, ngx_http_variable_request, 124 { ngx_string("server_protocol"), NULL, ngx_http_variable_request,
123 offsetof(ngx_http_request_t, http_protocol), 0, 0 }, 125 offsetof(ngx_http_request_t, http_protocol), 0, 0 },
124 126
127 { ngx_string("scheme"), NULL, ngx_http_variable_scheme, 0, 0, 0 },
128
125 { ngx_string("request_uri"), NULL, ngx_http_variable_request, 129 { ngx_string("request_uri"), NULL, ngx_http_variable_request,
126 offsetof(ngx_http_request_t, unparsed_uri), 0, 0 }, 130 offsetof(ngx_http_request_t, unparsed_uri), 0, 0 },
127 131
128 { ngx_string("uri"), NULL, ngx_http_variable_request, 132 { ngx_string("uri"), NULL, ngx_http_variable_request,
129 offsetof(ngx_http_request_t, uri), 133 offsetof(ngx_http_request_t, uri),
770 return NGX_OK; 774 return NGX_OK;
771 } 775 }
772 776
773 777
774 static ngx_int_t 778 static ngx_int_t
779 ngx_http_variable_scheme(ngx_http_request_t *r,
780 ngx_http_variable_value_t *v, uintptr_t data)
781 {
782 #if (NGX_HTTP_SSL)
783
784 if (r->connection->ssl) {
785 v->len = sizeof("https") - 1;
786 v->valid = 1;
787 v->no_cachable = 0;
788 v->not_found = 0;
789 v->data = (u_char *) "https";
790
791 return NGX_OK;
792 }
793
794 #endif
795
796 v->len = sizeof("http") - 1;
797 v->valid = 1;
798 v->no_cachable = 0;
799 v->not_found = 0;
800 v->data = (u_char *) "http";
801
802 return NGX_OK;
803 }
804
805
806 static ngx_int_t
775 ngx_http_variable_document_root(ngx_http_request_t *r, 807 ngx_http_variable_document_root(ngx_http_request_t *r,
776 ngx_http_variable_value_t *v, uintptr_t data) 808 ngx_http_variable_value_t *v, uintptr_t data)
777 { 809 {
778 ngx_str_t path; 810 ngx_str_t path;
779 ngx_http_core_loc_conf_t *clcf; 811 ngx_http_core_loc_conf_t *clcf;