Klaus Demo nginx / 49c9ea0
$scheme variable Igor Sysoev 15 years ago
1 changed file(s) with 32 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
3434 static ngx_int_t ngx_http_variable_server_addr(ngx_http_request_t *r,
3535 ngx_http_variable_value_t *v, uintptr_t data);
3636 static ngx_int_t ngx_http_variable_server_port(ngx_http_request_t *r,
37 ngx_http_variable_value_t *v, uintptr_t data);
38 static ngx_int_t ngx_http_variable_scheme(ngx_http_request_t *r,
3739 ngx_http_variable_value_t *v, uintptr_t data);
3840 static ngx_int_t ngx_http_variable_document_root(ngx_http_request_t *r,
3941 ngx_http_variable_value_t *v, uintptr_t data);
121123 { ngx_string("server_protocol"), NULL, ngx_http_variable_request,
122124 offsetof(ngx_http_request_t, http_protocol), 0, 0 },
123125
126 { ngx_string("scheme"), NULL, ngx_http_variable_scheme, 0, 0, 0 },
127
124128 { ngx_string("request_uri"), NULL, ngx_http_variable_request,
125129 offsetof(ngx_http_request_t, unparsed_uri), 0, 0 },
126130
771775
772776
773777 static ngx_int_t
778 ngx_http_variable_scheme(ngx_http_request_t *r,
779 ngx_http_variable_value_t *v, uintptr_t data)
780 {
781 #if (NGX_HTTP_SSL)
782
783 if (r->connection->ssl) {
784 v->len = sizeof("https") - 1;
785 v->valid = 1;
786 v->no_cachable = 0;
787 v->not_found = 0;
788 v->data = "https";
789
790 return NGX_OK;
791 }
792
793 #endif
794
795 v->len = sizeof("http") - 1;
796 v->valid = 1;
797 v->no_cachable = 0;
798 v->not_found = 0;
799 v->data = "http";
800
801 return NGX_OK;
802 }
803
804
805 static ngx_int_t
774806 ngx_http_variable_document_root(ngx_http_request_t *r,
775807 ngx_http_variable_value_t *v, uintptr_t data)
776808 {