Mercurial > hg > nginx
comparison src/http/ngx_http_core_module.c @ 201:267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 30 Nov 2003 20:03:18 +0000 |
parents | 8dee38ea9117 |
children | 4a9a2b1dd6fa |
comparison
equal
deleted
inserted
replaced
200:abeaebe0a33c | 201:267ea1d98683 |
---|---|
36 static ngx_conf_post_t ngx_http_lowat_post = { ngx_http_lowat_check } ; | 36 static ngx_conf_post_t ngx_http_lowat_post = { ngx_http_lowat_check } ; |
37 | 37 |
38 | 38 |
39 static ngx_command_t ngx_http_core_commands[] = { | 39 static ngx_command_t ngx_http_core_commands[] = { |
40 | 40 |
41 {ngx_string("server"), | 41 { ngx_string("server"), |
42 NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS, | 42 NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS, |
43 ngx_server_block, | 43 ngx_server_block, |
44 0, | 44 0, |
45 0, | 45 0, |
46 NULL}, | 46 NULL }, |
47 | 47 |
48 {ngx_string("connection_pool_size"), | 48 { ngx_string("connection_pool_size"), |
49 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | 49 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, |
50 ngx_conf_set_size_slot, | 50 ngx_conf_set_size_slot, |
51 NGX_HTTP_SRV_CONF_OFFSET, | 51 NGX_HTTP_SRV_CONF_OFFSET, |
52 offsetof(ngx_http_core_srv_conf_t, connection_pool_size), | 52 offsetof(ngx_http_core_srv_conf_t, connection_pool_size), |
53 NULL}, | 53 NULL }, |
54 | 54 |
55 {ngx_string("post_accept_timeout"), | 55 { ngx_string("post_accept_timeout"), |
56 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | 56 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, |
57 ngx_conf_set_msec_slot, | 57 ngx_conf_set_msec_slot, |
58 NGX_HTTP_SRV_CONF_OFFSET, | 58 NGX_HTTP_SRV_CONF_OFFSET, |
59 offsetof(ngx_http_core_srv_conf_t, post_accept_timeout), | 59 offsetof(ngx_http_core_srv_conf_t, post_accept_timeout), |
60 NULL}, | 60 NULL }, |
61 | 61 |
62 {ngx_string("request_pool_size"), | 62 { ngx_string("request_pool_size"), |
63 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | 63 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, |
64 ngx_conf_set_size_slot, | 64 ngx_conf_set_size_slot, |
65 NGX_HTTP_SRV_CONF_OFFSET, | 65 NGX_HTTP_SRV_CONF_OFFSET, |
66 offsetof(ngx_http_core_srv_conf_t, request_pool_size), | 66 offsetof(ngx_http_core_srv_conf_t, request_pool_size), |
67 NULL}, | 67 NULL }, |
68 | 68 |
69 {ngx_string("client_header_timeout"), | 69 { ngx_string("client_header_timeout"), |
70 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | 70 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, |
71 ngx_conf_set_msec_slot, | 71 ngx_conf_set_msec_slot, |
72 NGX_HTTP_SRV_CONF_OFFSET, | 72 NGX_HTTP_SRV_CONF_OFFSET, |
73 offsetof(ngx_http_core_srv_conf_t, client_header_timeout), | 73 offsetof(ngx_http_core_srv_conf_t, client_header_timeout), |
74 NULL}, | 74 NULL }, |
75 | 75 |
76 {ngx_string("client_header_buffer_size"), | 76 { ngx_string("client_header_buffer_size"), |
77 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | 77 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, |
78 ngx_conf_set_size_slot, | 78 ngx_conf_set_size_slot, |
79 NGX_HTTP_SRV_CONF_OFFSET, | 79 NGX_HTTP_SRV_CONF_OFFSET, |
80 offsetof(ngx_http_core_srv_conf_t, client_header_buffer_size), | 80 offsetof(ngx_http_core_srv_conf_t, client_header_buffer_size), |
81 NULL}, | 81 NULL }, |
82 | 82 |
83 {ngx_string("large_client_header"), | 83 { ngx_string("large_client_header"), |
84 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG, | 84 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG, |
85 ngx_conf_set_flag_slot, | 85 ngx_conf_set_flag_slot, |
86 NGX_HTTP_SRV_CONF_OFFSET, | 86 NGX_HTTP_SRV_CONF_OFFSET, |
87 offsetof(ngx_http_core_srv_conf_t, large_client_header), | 87 offsetof(ngx_http_core_srv_conf_t, large_client_header), |
88 NULL}, | 88 NULL }, |
89 | 89 |
90 {ngx_string("location"), | 90 { ngx_string("location"), |
91 NGX_HTTP_SRV_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE12, | 91 NGX_HTTP_SRV_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE12, |
92 ngx_location_block, | 92 ngx_location_block, |
93 NGX_HTTP_SRV_CONF_OFFSET, | 93 NGX_HTTP_SRV_CONF_OFFSET, |
94 0, | 94 0, |
95 NULL}, | 95 NULL }, |
96 | 96 |
97 {ngx_string("listen"), | 97 { ngx_string("listen"), |
98 #if 0 | 98 #if 0 |
99 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | 99 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, |
100 #else | 100 #else |
101 NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, | 101 NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, |
102 #endif | 102 #endif |
103 ngx_set_listen, | 103 ngx_set_listen, |
104 NGX_HTTP_SRV_CONF_OFFSET, | 104 NGX_HTTP_SRV_CONF_OFFSET, |
105 0, | 105 0, |
106 NULL}, | 106 NULL }, |
107 | 107 |
108 {ngx_string("server_name"), | 108 { ngx_string("server_name"), |
109 NGX_HTTP_SRV_CONF|NGX_CONF_1MORE, | 109 NGX_HTTP_SRV_CONF|NGX_CONF_1MORE, |
110 ngx_set_server_name, | 110 ngx_set_server_name, |
111 NGX_HTTP_SRV_CONF_OFFSET, | 111 NGX_HTTP_SRV_CONF_OFFSET, |
112 0, | 112 0, |
113 NULL}, | 113 NULL }, |
114 | 114 |
115 {ngx_string("types"), | 115 { ngx_string("types"), |
116 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF | 116 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF |
117 |NGX_CONF_BLOCK|NGX_CONF_NOARGS, | 117 |NGX_CONF_BLOCK|NGX_CONF_NOARGS, |
118 ngx_types_block, | 118 ngx_types_block, |
119 NGX_HTTP_LOC_CONF_OFFSET, | 119 NGX_HTTP_LOC_CONF_OFFSET, |
120 0, | 120 0, |
121 NULL}, | 121 NULL }, |
122 | 122 |
123 {ngx_string("default_type"), | 123 { ngx_string("default_type"), |
124 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 124 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
125 ngx_conf_set_str_slot, | 125 ngx_conf_set_str_slot, |
126 NGX_HTTP_LOC_CONF_OFFSET, | 126 NGX_HTTP_LOC_CONF_OFFSET, |
127 offsetof(ngx_http_core_loc_conf_t, default_type), | 127 offsetof(ngx_http_core_loc_conf_t, default_type), |
128 NULL}, | 128 NULL }, |
129 | 129 |
130 {ngx_string("root"), | 130 { ngx_string("root"), |
131 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 131 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
132 ngx_conf_set_str_slot, | 132 ngx_conf_set_str_slot, |
133 NGX_HTTP_LOC_CONF_OFFSET, | 133 NGX_HTTP_LOC_CONF_OFFSET, |
134 offsetof(ngx_http_core_loc_conf_t, doc_root), | 134 offsetof(ngx_http_core_loc_conf_t, doc_root), |
135 NULL}, | 135 NULL }, |
136 | 136 |
137 {ngx_string("client_body_timeout"), | 137 { ngx_string("client_body_timeout"), |
138 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 138 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
139 ngx_conf_set_msec_slot, | 139 ngx_conf_set_msec_slot, |
140 NGX_HTTP_LOC_CONF_OFFSET, | 140 NGX_HTTP_LOC_CONF_OFFSET, |
141 offsetof(ngx_http_core_loc_conf_t, client_body_timeout), | 141 offsetof(ngx_http_core_loc_conf_t, client_body_timeout), |
142 NULL}, | 142 NULL }, |
143 | 143 |
144 {ngx_string("sendfile"), | 144 { ngx_string("sendfile"), |
145 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | 145 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
146 ngx_conf_set_flag_slot, | 146 ngx_conf_set_flag_slot, |
147 NGX_HTTP_LOC_CONF_OFFSET, | 147 NGX_HTTP_LOC_CONF_OFFSET, |
148 offsetof(ngx_http_core_loc_conf_t, sendfile), | 148 offsetof(ngx_http_core_loc_conf_t, sendfile), |
149 NULL}, | 149 NULL }, |
150 | 150 |
151 {ngx_string("send_timeout"), | 151 { ngx_string("send_timeout"), |
152 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 152 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
153 ngx_conf_set_msec_slot, | 153 ngx_conf_set_msec_slot, |
154 NGX_HTTP_LOC_CONF_OFFSET, | 154 NGX_HTTP_LOC_CONF_OFFSET, |
155 offsetof(ngx_http_core_loc_conf_t, send_timeout), | 155 offsetof(ngx_http_core_loc_conf_t, send_timeout), |
156 NULL}, | 156 NULL }, |
157 | 157 |
158 {ngx_string("send_lowat"), | 158 { ngx_string("send_lowat"), |
159 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 159 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
160 ngx_conf_set_size_slot, | 160 ngx_conf_set_size_slot, |
161 NGX_HTTP_LOC_CONF_OFFSET, | 161 NGX_HTTP_LOC_CONF_OFFSET, |
162 offsetof(ngx_http_core_loc_conf_t, send_lowat), | 162 offsetof(ngx_http_core_loc_conf_t, send_lowat), |
163 &ngx_http_lowat_post}, | 163 &ngx_http_lowat_post }, |
164 | 164 |
165 {ngx_string("keepalive_timeout"), | 165 { ngx_string("keepalive_timeout"), |
166 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 166 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
167 ngx_conf_set_msec_slot, | 167 ngx_conf_set_msec_slot, |
168 NGX_HTTP_LOC_CONF_OFFSET, | 168 NGX_HTTP_LOC_CONF_OFFSET, |
169 offsetof(ngx_http_core_loc_conf_t, keepalive_timeout), | 169 offsetof(ngx_http_core_loc_conf_t, keepalive_timeout), |
170 NULL}, | 170 NULL }, |
171 | 171 |
172 {ngx_string("lingering_time"), | 172 { ngx_string("lingering_time"), |
173 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 173 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
174 ngx_conf_set_msec_slot, | 174 ngx_conf_set_msec_slot, |
175 NGX_HTTP_LOC_CONF_OFFSET, | 175 NGX_HTTP_LOC_CONF_OFFSET, |
176 offsetof(ngx_http_core_loc_conf_t, lingering_time), | 176 offsetof(ngx_http_core_loc_conf_t, lingering_time), |
177 NULL}, | 177 NULL }, |
178 | 178 |
179 {ngx_string("lingering_timeout"), | 179 { ngx_string("lingering_timeout"), |
180 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 180 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
181 ngx_conf_set_msec_slot, | 181 ngx_conf_set_msec_slot, |
182 NGX_HTTP_LOC_CONF_OFFSET, | 182 NGX_HTTP_LOC_CONF_OFFSET, |
183 offsetof(ngx_http_core_loc_conf_t, lingering_timeout), | 183 offsetof(ngx_http_core_loc_conf_t, lingering_timeout), |
184 NULL}, | 184 NULL }, |
185 | 185 |
186 {ngx_string("msie_padding"), | 186 { ngx_string("msie_padding"), |
187 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | 187 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
188 ngx_conf_set_flag_slot, | 188 ngx_conf_set_flag_slot, |
189 NGX_HTTP_LOC_CONF_OFFSET, | 189 NGX_HTTP_LOC_CONF_OFFSET, |
190 offsetof(ngx_http_core_loc_conf_t, msie_padding), | 190 offsetof(ngx_http_core_loc_conf_t, msie_padding), |
191 NULL}, | 191 NULL }, |
192 | 192 |
193 {ngx_string("error_page"), | 193 { ngx_string("error_page"), |
194 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_2MORE, | 194 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_2MORE, |
195 ngx_set_error_page, | 195 ngx_set_error_page, |
196 NGX_HTTP_LOC_CONF_OFFSET, | 196 NGX_HTTP_LOC_CONF_OFFSET, |
197 0, | 197 0, |
198 NULL}, | 198 NULL }, |
199 | 199 |
200 {ngx_string("error_log"), | 200 { ngx_string("error_log"), |
201 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 201 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
202 ngx_set_error_log, | 202 ngx_set_error_log, |
203 NGX_HTTP_LOC_CONF_OFFSET, | 203 NGX_HTTP_LOC_CONF_OFFSET, |
204 0, | 204 0, |
205 NULL}, | 205 NULL }, |
206 | 206 |
207 ngx_null_command | 207 { ngx_string("open_file_cache"), |
208 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE4, | |
209 ngx_http_set_cache_slot, | |
210 NGX_HTTP_LOC_CONF_OFFSET, | |
211 offsetof(ngx_http_core_loc_conf_t, open_files), | |
212 NULL }, | |
213 | |
214 ngx_null_command | |
208 }; | 215 }; |
209 | 216 |
210 | 217 |
211 ngx_http_module_t ngx_http_core_module_ctx = { | 218 ngx_http_module_t ngx_http_core_module_ctx = { |
212 NULL, /* pre conf */ | 219 NULL, /* pre conf */ |
299 } | 306 } |
300 | 307 |
301 | 308 |
302 static void ngx_http_run_phases(ngx_http_request_t *r) | 309 static void ngx_http_run_phases(ngx_http_request_t *r) |
303 { | 310 { |
304 int rc; | 311 char *path; |
312 ngx_int_t rc; | |
305 ngx_http_handler_pt *h; | 313 ngx_http_handler_pt *h; |
314 ngx_http_core_loc_conf_t *clcf; | |
306 ngx_http_core_main_conf_t *cmcf; | 315 ngx_http_core_main_conf_t *cmcf; |
307 | 316 |
308 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); | 317 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
309 | 318 |
310 rc = NGX_DECLINED; | |
311 | |
312 for (/* void */; r->phase < NGX_HTTP_LAST_PHASE; r->phase++) { | 319 for (/* void */; r->phase < NGX_HTTP_LAST_PHASE; r->phase++) { |
320 | |
321 if (r->phase == NGX_HTTP_CONTENT_PHASE && r->content_handler) { | |
322 r->connection->write->event_handler = ngx_http_empty_handler; | |
323 rc = r->content_handler(r); | |
324 ngx_http_finalize_request(r, rc); | |
325 return; | |
326 } | |
313 | 327 |
314 h = cmcf->phases[r->phase].handlers.elts; | 328 h = cmcf->phases[r->phase].handlers.elts; |
315 for (r->phase_handler = cmcf->phases[r->phase].handlers.nelts - 1; | 329 for (r->phase_handler = cmcf->phases[r->phase].handlers.nelts - 1; |
316 r->phase_handler >= 0; | 330 r->phase_handler >= 0; |
317 r->phase_handler--) | 331 r->phase_handler--) |
318 { | 332 { |
319 rc = h[r->phase_handler](r); | 333 rc = h[r->phase_handler](r); |
320 | 334 |
321 if (rc == NGX_DONE) { | 335 if (rc == NGX_DONE) { |
336 | |
337 /* | |
338 * we should never use r here because | |
339 * it could point to already freed data | |
340 */ | |
341 | |
322 return; | 342 return; |
323 } | 343 } |
324 | 344 |
325 if (rc == NGX_DECLINED) { | 345 if (rc == NGX_DECLINED) { |
326 continue; | 346 continue; |
328 | 348 |
329 if (rc == NGX_AGAIN) { | 349 if (rc == NGX_AGAIN) { |
330 return; | 350 return; |
331 } | 351 } |
332 | 352 |
333 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { | 353 if (rc >= NGX_HTTP_SPECIAL_RESPONSE || rc == NGX_ERROR) { |
334 ngx_http_finalize_request(r, rc); | 354 ngx_http_finalize_request(r, rc); |
335 return; | 355 return; |
336 } | 356 } |
337 | 357 |
358 if (rc == NGX_OK && r->phase == NGX_HTTP_CONTENT_PHASE) { | |
359 ngx_http_finalize_request(r, 0); | |
360 return; | |
361 } | |
362 | |
338 if (rc == NGX_OK && cmcf->phases[r->phase].type == NGX_OK) { | 363 if (rc == NGX_OK && cmcf->phases[r->phase].type == NGX_OK) { |
339 break; | 364 break; |
340 } | 365 } |
341 } | 366 } |
342 | 367 } |
343 if (cmcf->phases[r->phase].post_handler) { | 368 |
344 rc = cmcf->phases[r->phase].post_handler(r); | 369 |
345 | 370 if (r->uri.data[r->uri.len - 1] == '/') { |
346 if (rc == NGX_AGAIN) { | 371 |
347 return; | 372 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
348 } | 373 |
349 | 374 if (!(path = ngx_palloc(r->pool, clcf->doc_root.len + r->uri.len))) { |
350 if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) { | 375 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
351 ngx_http_finalize_request(r, rc); | 376 return; |
352 return; | 377 } |
353 } | 378 |
354 } | 379 ngx_cpystrn(ngx_cpymem(path, clcf->doc_root.data, clcf->doc_root.len), |
355 } | 380 r->uri.data, r->uri.len + 1); |
356 | 381 |
357 if (r->content_handler) { | 382 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
358 r->connection->write->event_handler = ngx_http_empty_handler; | 383 "directory index of \"%s\" is forbidden", path); |
359 rc = r->content_handler(r); | 384 |
360 ngx_http_finalize_request(r, rc); | 385 ngx_http_finalize_request(r, NGX_HTTP_FORBIDDEN); |
361 return; | 386 return; |
362 } | 387 } |
363 | 388 |
364 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | 389 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "no handler found"); |
390 | |
391 ngx_http_finalize_request(r, NGX_HTTP_NOT_FOUND); | |
365 return; | 392 return; |
366 } | 393 } |
367 | 394 |
368 | 395 |
369 int ngx_http_find_location_config(ngx_http_request_t *r) | 396 int ngx_http_find_location_config(ngx_http_request_t *r) |
492 * the translation phase | 519 * the translation phase |
493 */ | 520 */ |
494 | 521 |
495 r->content_handler = clcf->handler; | 522 r->content_handler = clcf->handler; |
496 r->phase++; | 523 r->phase++; |
524 } | |
525 | |
526 return NGX_OK; | |
527 } | |
528 | |
529 | |
530 ngx_int_t ngx_http_set_content_type(ngx_http_request_t *r) | |
531 { | |
532 uint32_t key; | |
533 ngx_int_t i; | |
534 ngx_http_type_t *type; | |
535 ngx_http_core_loc_conf_t *clcf; | |
536 | |
537 if (!(r->headers_out.content_type = | |
538 ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) | |
539 { | |
540 return NGX_HTTP_INTERNAL_SERVER_ERROR; | |
541 } | |
542 | |
543 r->headers_out.content_type->key.len = 0; | |
544 r->headers_out.content_type->key.data = NULL; | |
545 r->headers_out.content_type->value.len = 0; | |
546 r->headers_out.content_type->value.data = NULL; | |
547 | |
548 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
549 | |
550 if (r->exten.len) { | |
551 #if 0 | |
552 key = ngx_crc(r->exten.data, r->exten.key); | |
553 #endif | |
554 ngx_http_types_hash_key(key, r->exten); | |
555 | |
556 type = clcf->types[key].elts; | |
557 for (i = 0; i < clcf->types[key].nelts; i++) { | |
558 if (r->exten.len != type[i].exten.len) { | |
559 continue; | |
560 } | |
561 | |
562 if (ngx_memcmp(r->exten.data, type[i].exten.data, r->exten.len) | |
563 == 0) | |
564 { | |
565 r->headers_out.content_type->value = type[i].type; | |
566 break; | |
567 } | |
568 } | |
569 } | |
570 | |
571 if (r->headers_out.content_type->value.len == 0) { | |
572 r->headers_out.content_type->value = clcf->default_type; | |
497 } | 573 } |
498 | 574 |
499 return NGX_OK; | 575 return NGX_OK; |
500 } | 576 } |
501 | 577 |
868 { | 944 { |
869 ngx_http_core_loc_conf_t *lcf = conf; | 945 ngx_http_core_loc_conf_t *lcf = conf; |
870 | 946 |
871 int i, key; | 947 int i, key; |
872 ngx_str_t *args; | 948 ngx_str_t *args; |
873 ngx_http_type_t *t; | 949 ngx_http_type_t *type; |
874 | 950 |
875 if (lcf->types == NULL) { | 951 if (lcf->types == NULL) { |
876 ngx_test_null(lcf->types, | 952 ngx_test_null(lcf->types, |
877 ngx_palloc(cf->pool, NGX_HTTP_TYPES_HASH_PRIME | 953 ngx_palloc(cf->pool, NGX_HTTP_TYPES_HASH_PRIME |
878 * sizeof(ngx_array_t)), | 954 * sizeof(ngx_array_t)), |
887 args = (ngx_str_t *) cf->args->elts; | 963 args = (ngx_str_t *) cf->args->elts; |
888 | 964 |
889 for (i = 1; i < cf->args->nelts; i++) { | 965 for (i = 1; i < cf->args->nelts; i++) { |
890 ngx_http_types_hash_key(key, args[i]); | 966 ngx_http_types_hash_key(key, args[i]); |
891 | 967 |
892 ngx_test_null(t, ngx_push_array(&lcf->types[key]), NGX_CONF_ERROR); | 968 ngx_test_null(type, ngx_push_array(&lcf->types[key]), NGX_CONF_ERROR); |
893 t->exten.len = args[i].len; | 969 type->exten = args[i]; |
894 t->exten.data = args[i].data; | 970 type->type = args[0]; |
895 t->type.len = args[0].len; | |
896 t->type.data = args[0].data; | |
897 } | 971 } |
898 | 972 |
899 return NGX_CONF_OK; | 973 return NGX_CONF_OK; |
900 } | 974 } |
901 | 975 |
1122 ngx_conf_merge_msec_value(conf->lingering_timeout, | 1196 ngx_conf_merge_msec_value(conf->lingering_timeout, |
1123 prev->lingering_timeout, 5000); | 1197 prev->lingering_timeout, 5000); |
1124 | 1198 |
1125 ngx_conf_merge_value(conf->msie_padding, prev->msie_padding, 1); | 1199 ngx_conf_merge_value(conf->msie_padding, prev->msie_padding, 1); |
1126 | 1200 |
1201 if (conf->open_files == NULL) { | |
1202 conf->open_files = prev->open_files; | |
1203 } | |
1204 | |
1127 return NGX_CONF_OK; | 1205 return NGX_CONF_OK; |
1128 } | 1206 } |
1129 | 1207 |
1130 | 1208 |
1131 static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 1209 static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |