annotate src/http/modules/ngx_http_index_module.c @ 572:ff463db0be31 NGINX_0_8_38

nginx 0.8.38 *) Feature: the "proxy_no_cache" and "fastcgi_no_cache" directives. *) Feature: now the "rewrite" directive does a redirect automatically if the $scheme variable is used. Thanks to Piotr Sikora. *) Bugfix: now "limit_req" delay directive conforms to the described algorithm. Thanks to Maxim Dounin. *) Bugfix: the $uid_got variable might not be used in the SSI and perl modules.
author Igor Sysoev <http://sysoev.ru>
date Mon, 24 May 2010 00:00:00 +0400
parents f7ec98e3caeb
children d0f7a625f27c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
2 /*
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
3 * Copyright (C) Igor Sysoev
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
4 */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
5
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
6
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
7 #include <ngx_config.h>
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
8 #include <ngx_core.h>
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
9 #include <ngx_http.h>
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
10
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
11
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
12 typedef struct {
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
13 ngx_str_t name;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
14 ngx_array_t *lengths;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
15 ngx_array_t *values;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
16 } ngx_http_index_t;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
17
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
18
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
19 typedef struct {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
20 ngx_array_t *indices; /* array of ngx_http_index_t */
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
21 size_t max_index_len;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
22 } ngx_http_index_loc_conf_t;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
23
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
24
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
25 #define NGX_HTTP_DEFAULT_INDEX "index.html"
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
26
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
27
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
28 static ngx_int_t ngx_http_index_test_dir(ngx_http_request_t *r,
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
29 ngx_http_core_loc_conf_t *clcf, u_char *path, u_char *last);
394
05981f639d21 nginx 0.7.9
Igor Sysoev <http://sysoev.ru>
parents: 390
diff changeset
30 static ngx_int_t ngx_http_index_error(ngx_http_request_t *r,
05981f639d21 nginx 0.7.9
Igor Sysoev <http://sysoev.ru>
parents: 390
diff changeset
31 ngx_http_core_loc_conf_t *clcf, u_char *file, ngx_err_t err);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
32
230
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
33 static ngx_int_t ngx_http_index_init(ngx_conf_t *cf);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
34 static void *ngx_http_index_create_loc_conf(ngx_conf_t *cf);
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
35 static char *ngx_http_index_merge_loc_conf(ngx_conf_t *cf,
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
36 void *parent, void *child);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
37 static char *ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd,
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
38 void *conf);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
39
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
40
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
41 static ngx_command_t ngx_http_index_commands[] = {
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
42
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
43 { ngx_string("index"),
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
44 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
45 ngx_http_index_set_index,
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
46 NGX_HTTP_LOC_CONF_OFFSET,
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
47 0,
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
48 NULL },
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
49
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
50 ngx_null_command
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
51 };
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
52
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
53
216
fa32d59d9a15 nginx 0.3.55
Igor Sysoev <http://sysoev.ru>
parents: 210
diff changeset
54 static ngx_http_module_t ngx_http_index_module_ctx = {
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
55 NULL, /* preconfiguration */
230
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
56 ngx_http_index_init, /* postconfiguration */
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
57
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
58 NULL, /* create main configuration */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
59 NULL, /* init main configuration */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
60
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
61 NULL, /* create server configuration */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
62 NULL, /* merge server configuration */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
63
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
64 ngx_http_index_create_loc_conf, /* create location configration */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
65 ngx_http_index_merge_loc_conf /* merge location configration */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
66 };
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
67
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
68
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
69 ngx_module_t ngx_http_index_module = {
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
70 NGX_MODULE_V1,
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
71 &ngx_http_index_module_ctx, /* module context */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
72 ngx_http_index_commands, /* module directives */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
73 NGX_HTTP_MODULE, /* module type */
90
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
74 NULL, /* init master */
230
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
75 NULL, /* init module */
90
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
76 NULL, /* init process */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
77 NULL, /* init thread */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
78 NULL, /* exit thread */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
79 NULL, /* exit process */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
80 NULL, /* exit master */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
81 NGX_MODULE_V1_PADDING
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
82 };
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
83
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
84
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
85 /*
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
86 * Try to open/test the first index file before the test of directory
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
87 * existence because valid requests should be much more than invalid ones.
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
88 * If the file open()/stat() would fail, then the directory stat() should
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
89 * be more quickly because some data is already cached in the kernel.
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
90 * Besides, Win32 may return ERROR_PATH_NOT_FOUND (NGX_ENOTDIR) at once.
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
91 * Unix has ENOTDIR error, however, it's less helpful than Win32's one:
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
92 * it only indicates that path contains an usual file in place of directory.
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
93 */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
94
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
95 static ngx_int_t
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
96 ngx_http_index_handler(ngx_http_request_t *r)
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
97 {
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
98 u_char *p, *name;
442
670af56a1158 nginx 0.7.33
Igor Sysoev <http://sysoev.ru>
parents: 430
diff changeset
99 size_t len, root, reserve, allocated;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
100 ngx_int_t rc;
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
101 ngx_str_t path, uri;
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
102 ngx_uint_t i, dir_tested;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
103 ngx_http_index_t *index;
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
104 ngx_open_file_info_t of;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
105 ngx_http_script_code_pt code;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
106 ngx_http_script_engine_t e;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
107 ngx_http_core_loc_conf_t *clcf;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
108 ngx_http_index_loc_conf_t *ilcf;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
109 ngx_http_script_len_code_pt lcode;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
110
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
111 if (r->uri.data[r->uri.len - 1] != '/') {
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
112 return NGX_DECLINED;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
113 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
114
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 252
diff changeset
115 if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD|NGX_HTTP_POST))) {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 252
diff changeset
116 return NGX_DECLINED;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 252
diff changeset
117 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 252
diff changeset
118
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
119 ilcf = ngx_http_get_module_loc_conf(r, ngx_http_index_module);
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
120 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
121
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
122 allocated = 0;
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
123 root = 0;
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
124 dir_tested = 0;
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
125 name = NULL;
442
670af56a1158 nginx 0.7.33
Igor Sysoev <http://sysoev.ru>
parents: 430
diff changeset
126 /* suppress MSVC warning */
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
127 path.data = NULL;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
128
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
129 index = ilcf->indices->elts;
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
130 for (i = 0; i < ilcf->indices->nelts; i++) {
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
131
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
132 if (index[i].lengths == NULL) {
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
133
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
134 if (index[i].name.data[0] == '/') {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
135 return ngx_http_internal_redirect(r, &index[i].name, &r->args);
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
136 }
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
137
442
670af56a1158 nginx 0.7.33
Igor Sysoev <http://sysoev.ru>
parents: 430
diff changeset
138 reserve = ilcf->max_index_len;
670af56a1158 nginx 0.7.33
Igor Sysoev <http://sysoev.ru>
parents: 430
diff changeset
139 len = index[i].name.len;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
140
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
141 } else {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
142 ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
143
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
144 e.ip = index[i].lengths->elts;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
145 e.request = r;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 112
diff changeset
146 e.flushed = 1;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
147
442
670af56a1158 nginx 0.7.33
Igor Sysoev <http://sysoev.ru>
parents: 430
diff changeset
148 /* 1 is for terminating '\0' as in static names */
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 106
diff changeset
149 len = 1;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
150
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
151 while (*(uintptr_t *) e.ip) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
152 lcode = *(ngx_http_script_len_code_pt *) e.ip;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
153 len += lcode(&e);
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
154 }
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
155
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 106
diff changeset
156 /* 16 bytes are preallocation */
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 106
diff changeset
157
442
670af56a1158 nginx 0.7.33
Igor Sysoev <http://sysoev.ru>
parents: 430
diff changeset
158 reserve = len + 16;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
159 }
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
160
442
670af56a1158 nginx 0.7.33
Igor Sysoev <http://sysoev.ru>
parents: 430
diff changeset
161 if (reserve > allocated) {
106
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
162
442
670af56a1158 nginx 0.7.33
Igor Sysoev <http://sysoev.ru>
parents: 430
diff changeset
163 name = ngx_http_map_uri_to_path(r, &path, &root, reserve);
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
164 if (name == NULL) {
106
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
165 return NGX_ERROR;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
166 }
106
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
167
442
670af56a1158 nginx 0.7.33
Igor Sysoev <http://sysoev.ru>
parents: 430
diff changeset
168 allocated = path.data + path.len - name;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
169 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
170
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
171 if (index[i].values == NULL) {
106
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
172
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
173 /* index[i].name.len includes the terminating '\0' */
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
174
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
175 ngx_memcpy(name, index[i].name.data, index[i].name.len);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
176
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
177 path.len = (name + index[i].name.len - 1) - path.data;
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
178
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
179 } else {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
180 e.ip = index[i].values->elts;
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
181 e.pos = name;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
182
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
183 while (*(uintptr_t *) e.ip) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
184 code = *(ngx_http_script_code_pt *) e.ip;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
185 code((ngx_http_script_engine_t *) &e);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
186 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
187
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
188 if (*name == '/') {
442
670af56a1158 nginx 0.7.33
Igor Sysoev <http://sysoev.ru>
parents: 430
diff changeset
189 uri.len = len - 1;
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
190 uri.data = name;
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
191 return ngx_http_internal_redirect(r, &uri, &r->args);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
192 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
193
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
194 path.len = e.pos - path.data;
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
195
460
bb941a2996a6 nginx 0.7.42
Igor Sysoev <http://sysoev.ru>
parents: 442
diff changeset
196 *e.pos = '\0';
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
197 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
198
430
dac47e9ef0d5 nginx 0.7.27
Igor Sysoev <http://sysoev.ru>
parents: 398
diff changeset
199 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
dac47e9ef0d5 nginx 0.7.27
Igor Sysoev <http://sysoev.ru>
parents: 398
diff changeset
200 "open index \"%V\"", &path);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
201
384
12defd37f578 nginx 0.7.4
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
202 ngx_memzero(&of, sizeof(ngx_open_file_info_t));
12defd37f578 nginx 0.7.4
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
203
532
f7ec98e3caeb nginx 0.8.18
Igor Sysoev <http://sysoev.ru>
parents: 530
diff changeset
204 of.read_ahead = clcf->read_ahead;
390
0b6053502c55 nginx 0.7.7
Igor Sysoev <http://sysoev.ru>
parents: 384
diff changeset
205 of.directio = clcf->directio;
358
9121a0a91f47 nginx 0.6.23
Igor Sysoev <http://sysoev.ru>
parents: 346
diff changeset
206 of.valid = clcf->open_file_cache_valid;
9121a0a91f47 nginx 0.6.23
Igor Sysoev <http://sysoev.ru>
parents: 346
diff changeset
207 of.min_uses = clcf->open_file_cache_min_uses;
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
208 of.test_only = 1;
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
209 of.errors = clcf->open_file_cache_errors;
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
210 of.events = clcf->open_file_cache_events;
112
408f195b3482 nginx 0.3.3
Igor Sysoev <http://sysoev.ru>
parents: 106
diff changeset
211
362
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 358
diff changeset
212 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 358
diff changeset
213 != NGX_OK)
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 358
diff changeset
214 {
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
215 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, of.err,
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
216 "%s \"%s\" failed", of.failed, path.data);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
217
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
218 if (of.err == 0) {
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
219 return NGX_HTTP_INTERNAL_SERVER_ERROR;
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
220 }
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
221
530
4c5d2c627a6c nginx 0.8.17
Igor Sysoev <http://sysoev.ru>
parents: 496
diff changeset
222 if (of.err == NGX_ENOTDIR
4c5d2c627a6c nginx 0.8.17
Igor Sysoev <http://sysoev.ru>
parents: 496
diff changeset
223 || of.err == NGX_ENAMETOOLONG
4c5d2c627a6c nginx 0.8.17
Igor Sysoev <http://sysoev.ru>
parents: 496
diff changeset
224 || of.err == NGX_EACCES)
4c5d2c627a6c nginx 0.8.17
Igor Sysoev <http://sysoev.ru>
parents: 496
diff changeset
225 {
394
05981f639d21 nginx 0.7.9
Igor Sysoev <http://sysoev.ru>
parents: 390
diff changeset
226 return ngx_http_index_error(r, clcf, path.data, of.err);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
227 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
228
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
229 if (!dir_tested) {
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
230 rc = ngx_http_index_test_dir(r, clcf, path.data, name - 1);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
231
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
232 if (rc != NGX_OK) {
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
233 return rc;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
234 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
235
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
236 dir_tested = 1;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
237 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
238
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
239 if (of.err == NGX_ENOENT) {
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
240 continue;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
241 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
242
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
243 ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err,
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
244 "%s \"%s\" failed", of.failed, path.data);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
245
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
246 return NGX_HTTP_INTERNAL_SERVER_ERROR;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
247 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
248
442
670af56a1158 nginx 0.7.33
Igor Sysoev <http://sysoev.ru>
parents: 430
diff changeset
249 uri.len = r->uri.len + len - 1;
106
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
250
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
251 if (!clcf->alias) {
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
252 uri.data = path.data + root;
106
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
253
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
254 } else {
382
984bb0b1399b nginx 0.7.3
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
255 uri.data = ngx_pnalloc(r->pool, uri.len);
106
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
256 if (uri.data == NULL) {
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
257 return NGX_HTTP_INTERNAL_SERVER_ERROR;
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
258 }
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
259
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
260 p = ngx_copy(uri.data, r->uri.data, r->uri.len);
442
670af56a1158 nginx 0.7.33
Igor Sysoev <http://sysoev.ru>
parents: 430
diff changeset
261 ngx_memcpy(p, name, len - 1);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
262 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
263
106
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
264 return ngx_http_internal_redirect(r, &uri, &r->args);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
265 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
266
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
267 return NGX_DECLINED;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
268 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
269
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
270
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
271 static ngx_int_t
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
272 ngx_http_index_test_dir(ngx_http_request_t *r, ngx_http_core_loc_conf_t *clcf,
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
273 u_char *path, u_char *last)
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
274 {
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
275 u_char c;
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
276 ngx_str_t dir;
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
277 ngx_open_file_info_t of;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
278
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
279 c = *last;
346
05693816539c nginx 0.6.17
Igor Sysoev <http://sysoev.ru>
parents: 344
diff changeset
280 if (c != '/' || path == last) {
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
281 /* "alias" without trailing slash */
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
282 c = *(++last);
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
283 }
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
284 *last = '\0';
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
285
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
286 dir.len = last - path;
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
287 dir.data = path;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
288
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
289 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
290 "http index check dir: \"%V\"", &dir);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
291
384
12defd37f578 nginx 0.7.4
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
292 ngx_memzero(&of, sizeof(ngx_open_file_info_t));
12defd37f578 nginx 0.7.4
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
293
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
294 of.test_dir = 1;
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
295 of.test_only = 1;
358
9121a0a91f47 nginx 0.6.23
Igor Sysoev <http://sysoev.ru>
parents: 346
diff changeset
296 of.valid = clcf->open_file_cache_valid;
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
297 of.errors = clcf->open_file_cache_errors;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
298
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
299 if (ngx_open_cached_file(clcf->open_file_cache, &dir, &of, r->pool)
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
300 != NGX_OK)
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
301 {
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
302 if (of.err) {
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
303
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
304 if (of.err == NGX_ENOENT) {
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
305 *last = c;
394
05981f639d21 nginx 0.7.9
Igor Sysoev <http://sysoev.ru>
parents: 390
diff changeset
306 return ngx_http_index_error(r, clcf, dir.data, NGX_ENOENT);
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
307 }
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
308
398
9d81578d04bb nginx 0.7.11
Igor Sysoev <http://sysoev.ru>
parents: 394
diff changeset
309 if (of.err == NGX_EACCES) {
9d81578d04bb nginx 0.7.11
Igor Sysoev <http://sysoev.ru>
parents: 394
diff changeset
310
9d81578d04bb nginx 0.7.11
Igor Sysoev <http://sysoev.ru>
parents: 394
diff changeset
311 *last = c;
9d81578d04bb nginx 0.7.11
Igor Sysoev <http://sysoev.ru>
parents: 394
diff changeset
312
9d81578d04bb nginx 0.7.11
Igor Sysoev <http://sysoev.ru>
parents: 394
diff changeset
313 /*
9d81578d04bb nginx 0.7.11
Igor Sysoev <http://sysoev.ru>
parents: 394
diff changeset
314 * ngx_http_index_test_dir() is called after the first index
9d81578d04bb nginx 0.7.11
Igor Sysoev <http://sysoev.ru>
parents: 394
diff changeset
315 * file testing has returned an error distinct from NGX_EACCES.
9d81578d04bb nginx 0.7.11
Igor Sysoev <http://sysoev.ru>
parents: 394
diff changeset
316 * This means that directory searching is allowed.
9d81578d04bb nginx 0.7.11
Igor Sysoev <http://sysoev.ru>
parents: 394
diff changeset
317 */
9d81578d04bb nginx 0.7.11
Igor Sysoev <http://sysoev.ru>
parents: 394
diff changeset
318
9d81578d04bb nginx 0.7.11
Igor Sysoev <http://sysoev.ru>
parents: 394
diff changeset
319 return NGX_OK;
9d81578d04bb nginx 0.7.11
Igor Sysoev <http://sysoev.ru>
parents: 394
diff changeset
320 }
9d81578d04bb nginx 0.7.11
Igor Sysoev <http://sysoev.ru>
parents: 394
diff changeset
321
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
322 ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err,
482
392c16f2d858 nginx 0.7.53
Igor Sysoev <http://sysoev.ru>
parents: 480
diff changeset
323 "%s \"%s\" failed", of.failed, dir.data);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
324 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
325
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
326 return NGX_HTTP_INTERNAL_SERVER_ERROR;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
327 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
328
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
329 *last = c;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
330
332
3a91bfeffaba nginx 0.6.10
Igor Sysoev <http://sysoev.ru>
parents: 276
diff changeset
331 if (of.is_dir) {
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
332 return NGX_OK;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
333 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
334
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
335 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
336 "\"%s\" is not a directory", dir.data);
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
337
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
338 return NGX_HTTP_INTERNAL_SERVER_ERROR;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
339 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
340
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
341
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
342 static ngx_int_t
394
05981f639d21 nginx 0.7.9
Igor Sysoev <http://sysoev.ru>
parents: 390
diff changeset
343 ngx_http_index_error(ngx_http_request_t *r, ngx_http_core_loc_conf_t *clcf,
05981f639d21 nginx 0.7.9
Igor Sysoev <http://sysoev.ru>
parents: 390
diff changeset
344 u_char *file, ngx_err_t err)
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
345 {
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
346 if (err == NGX_EACCES) {
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
347 ngx_log_error(NGX_LOG_ERR, r->connection->log, err,
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
348 "\"%s\" is forbidden", file);
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
349
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
350 return NGX_HTTP_FORBIDDEN;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
351 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
352
394
05981f639d21 nginx 0.7.9
Igor Sysoev <http://sysoev.ru>
parents: 390
diff changeset
353 if (clcf->log_not_found) {
05981f639d21 nginx 0.7.9
Igor Sysoev <http://sysoev.ru>
parents: 390
diff changeset
354 ngx_log_error(NGX_LOG_ERR, r->connection->log, err,
05981f639d21 nginx 0.7.9
Igor Sysoev <http://sysoev.ru>
parents: 390
diff changeset
355 "\"%s\" is not found", file);
05981f639d21 nginx 0.7.9
Igor Sysoev <http://sysoev.ru>
parents: 390
diff changeset
356 }
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
357
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
358 return NGX_HTTP_NOT_FOUND;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
359 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
360
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
361
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
362 static void *
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
363 ngx_http_index_create_loc_conf(ngx_conf_t *cf)
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
364 {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
365 ngx_http_index_loc_conf_t *conf;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
366
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
367 conf = ngx_palloc(cf->pool, sizeof(ngx_http_index_loc_conf_t));
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
368 if (conf == NULL) {
496
f39b9e29530d nginx 0.8.0
Igor Sysoev <http://sysoev.ru>
parents: 482
diff changeset
369 return NULL;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
370 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
371
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
372 conf->indices = NULL;
230
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
373 conf->max_index_len = 0;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
374
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
375 return conf;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
376 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
377
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
378
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
379 static char *
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
380 ngx_http_index_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
381 {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
382 ngx_http_index_loc_conf_t *prev = parent;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
383 ngx_http_index_loc_conf_t *conf = child;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
384
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
385 ngx_http_index_t *index;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
386
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
387 if (conf->indices == NULL) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
388 conf->indices = prev->indices;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
389 conf->max_index_len = prev->max_index_len;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
390 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
391
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
392 if (conf->indices == NULL) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
393 conf->indices = ngx_array_create(cf->pool, 1, sizeof(ngx_http_index_t));
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
394 if (conf->indices == NULL) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
395 return NGX_CONF_ERROR;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
396 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
397
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
398 index = ngx_array_push(conf->indices);
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
399 if (index == NULL) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
400 return NGX_CONF_ERROR;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
401 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
402
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
403 index->name.len = sizeof(NGX_HTTP_DEFAULT_INDEX);
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
404 index->name.data = (u_char *) NGX_HTTP_DEFAULT_INDEX;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
405 index->lengths = NULL;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
406 index->values = NULL;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
407
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
408 conf->max_index_len = sizeof(NGX_HTTP_DEFAULT_INDEX);
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
409
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
410 return NGX_CONF_OK;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
411 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
412
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
413 return NGX_CONF_OK;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
414 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
415
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
416
230
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
417 static ngx_int_t
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
418 ngx_http_index_init(ngx_conf_t *cf)
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
419 {
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
420 ngx_http_handler_pt *h;
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
421 ngx_http_core_main_conf_t *cmcf;
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
422
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
423 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
424
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
425 h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
426 if (h == NULL) {
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
427 return NGX_ERROR;
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
428 }
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
429
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
430 *h = ngx_http_index_handler;
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
431
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
432 return NGX_OK;
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
433 }
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
434
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
435
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
436 /* TODO: warn about duplicate indices */
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
437
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
438 static char *
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
439 ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
440 {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
441 ngx_http_index_loc_conf_t *ilcf = conf;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
442
230
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
443 ngx_str_t *value;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
444 ngx_uint_t i, n;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
445 ngx_http_index_t *index;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
446 ngx_http_script_compile_t sc;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
447
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
448 if (ilcf->indices == NULL) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
449 ilcf->indices = ngx_array_create(cf->pool, 2, sizeof(ngx_http_index_t));
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
450 if (ilcf->indices == NULL) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
451 return NGX_CONF_ERROR;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
452 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
453 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
454
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
455 value = cf->args->elts;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
456
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
457 for (i = 1; i < cf->args->nelts; i++) {
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
458
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
459 if (value[i].data[0] == '/' && i != cf->args->nelts - 1) {
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
460 ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
461 "only the last index in \"index\" directive "
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
462 "should be absolute");
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
463 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
464
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
465 if (value[i].len == 0) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
466 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
467 "index \"%V\" in \"index\" directive is invalid",
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
468 &value[1]);
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
469 return NGX_CONF_ERROR;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
470 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
471
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
472 index = ngx_array_push(ilcf->indices);
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
473 if (index == NULL) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
474 return NGX_CONF_ERROR;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
475 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
476
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
477 index->name.len = value[i].len;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
478 index->name.data = value[i].data;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
479 index->lengths = NULL;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
480 index->values = NULL;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
481
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
482 n = ngx_http_script_variables_count(&value[i]);
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
483
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
484 if (n == 0) {
230
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
485 if (ilcf->max_index_len < index->name.len) {
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
486 ilcf->max_index_len = index->name.len;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
487 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
488
344
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
489 if (index->name.data[0] == '/') {
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
490 continue;
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
491 }
eae74a780a84 nginx 0.6.16
Igor Sysoev <http://sysoev.ru>
parents: 332
diff changeset
492
442
670af56a1158 nginx 0.7.33
Igor Sysoev <http://sysoev.ru>
parents: 430
diff changeset
493 /* include the terminating '\0' to the length to use ngx_memcpy() */
106
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
494 index->name.len++;
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 90
diff changeset
495
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
496 continue;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
497 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
498
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
499 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
500
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
501 sc.cf = cf;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
502 sc.source = &value[i];
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
503 sc.lengths = &index->lengths;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
504 sc.values = &index->values;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
505 sc.variables = n;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
506 sc.complete_lengths = 1;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
507 sc.complete_values = 1;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
508
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
509 if (ngx_http_script_compile(&sc) != NGX_OK) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
510 return NGX_CONF_ERROR;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
511 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
512 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
513
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
514 return NGX_CONF_OK;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
515 }