comparison src/http/ngx_http_variables.c @ 731:44161d685b8a

$scheme variable
author Igor Sysoev <igor@sysoev.ru>
date Mon, 02 Oct 2006 11:07:36 +0000
parents cec32b3753ac
children 5e42c1615f4d
comparison
equal deleted inserted replaced
730:1be87cdd010f 731:44161d685b8a
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 = "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 = "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;