Mercurial > hg > nginx
comparison src/http/ngx_http_core_module.c @ 69:e43f406e4525
nginx-0.0.1-2003-03-20-19:09:44 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 20 Mar 2003 16:09:44 +0000 |
parents | 5a7d1aaa1618 |
children | 59229033ae93 |
comparison
equal
deleted
inserted
replaced
68:d549fdc17d7e | 69:e43f406e4525 |
---|---|
17 int ngx_http_proxy_handler(ngx_http_request_t *r); | 17 int ngx_http_proxy_handler(ngx_http_request_t *r); |
18 /**/ | 18 /**/ |
19 | 19 |
20 static int ngx_http_core_index_handler(ngx_http_request_t *r); | 20 static int ngx_http_core_index_handler(ngx_http_request_t *r); |
21 | 21 |
22 static int ngx_http_core_init(ngx_pool_t *pool); | |
23 | |
24 static void *ngx_http_core_create_srv_conf(ngx_pool_t *pool); | |
25 static char *ngx_http_core_init_srv_conf(ngx_pool_t *pool, void *conf); | |
26 static void *ngx_http_core_create_loc_conf(ngx_pool_t *pool); | |
27 | |
22 static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy); | 28 static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy); |
23 static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, | 29 static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, |
24 char *dummy); | 30 char *dummy); |
25 static void *ngx_http_core_create_srv_conf(ngx_pool_t *pool); | |
26 static char *ngx_http_core_init_srv_conf(ngx_pool_t *pool, void *conf); | |
27 static void *ngx_http_core_create_loc_conf(ngx_pool_t *pool); | |
28 static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, char *conf); | 31 static char *ngx_set_listen(ngx_conf_t *cf, ngx_command_t *cmd, char *conf); |
29 | 32 |
30 | 33 |
31 static ngx_command_t ngx_http_core_commands[] = { | 34 static ngx_command_t ngx_http_core_commands[] = { |
32 | 35 |
106 NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1, | 109 NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1, |
107 ngx_conf_set_time_slot, | 110 ngx_conf_set_time_slot, |
108 NGX_HTTP_LOC_CONF_OFFSET, | 111 NGX_HTTP_LOC_CONF_OFFSET, |
109 offsetof(ngx_http_core_loc_conf_t, lingering_timeout)}, | 112 offsetof(ngx_http_core_loc_conf_t, lingering_timeout)}, |
110 | 113 |
111 {ngx_string(""), 0, NULL, 0, 0} | 114 {ngx_null_string, 0, NULL, 0, 0} |
112 }; | 115 }; |
113 | 116 |
114 | 117 |
115 ngx_http_module_t ngx_http_core_module_ctx = { | 118 ngx_http_module_t ngx_http_core_module_ctx = { |
116 NGX_HTTP_MODULE, | |
117 | |
118 ngx_http_core_create_srv_conf, /* create server config */ | 119 ngx_http_core_create_srv_conf, /* create server config */ |
119 ngx_http_core_init_srv_conf, /* init server config */ | 120 ngx_http_core_init_srv_conf, /* init server config */ |
121 | |
120 ngx_http_core_create_loc_conf, /* create location config */ | 122 ngx_http_core_create_loc_conf, /* create location config */ |
121 NULL, /* merge location config */ | 123 NULL, /* merge location config */ |
122 | 124 |
123 ngx_http_core_translate_handler, /* translate handler */ | 125 NULL /* init filters */ |
124 | |
125 NULL, /* output header filter */ | |
126 NULL, /* next output header filter */ | |
127 NULL, /* output body filter */ | |
128 NULL /* next output body filter */ | |
129 }; | 126 }; |
130 | 127 |
131 | 128 |
132 ngx_module_t ngx_http_core_module = { | 129 ngx_module_t ngx_http_core_module = { |
133 0, /* module index */ | 130 0, /* module index */ |
134 &ngx_http_core_module_ctx, /* module context */ | 131 &ngx_http_core_module_ctx, /* module context */ |
135 ngx_http_core_commands, /* module directives */ | 132 ngx_http_core_commands, /* module directives */ |
136 NGX_HTTP_MODULE_TYPE, /* module type */ | 133 NGX_HTTP_MODULE_TYPE, /* module type */ |
137 NULL /* init module */ | 134 ngx_http_core_init /* init module */ |
138 }; | 135 }; |
139 | 136 |
140 | 137 |
141 int ngx_http_handler(ngx_http_request_t *r) | 138 int ngx_http_handler(ngx_http_request_t *r) |
142 { | 139 { |
143 int rc, a, n, i; | 140 int rc, a, n, i; |
141 ngx_http_handler_pt *h; | |
144 ngx_http_module_t *module; | 142 ngx_http_module_t *module; |
145 ngx_http_conf_ctx_t *ctx; | 143 ngx_http_conf_ctx_t *ctx; |
146 ngx_http_in_port_t *in_port; | 144 ngx_http_in_port_t *in_port; |
147 ngx_http_in_addr_t *in_addr; | 145 ngx_http_in_addr_t *in_addr; |
148 ngx_http_server_name_t *name; | 146 ngx_http_server_name_t *name; |
149 | 147 |
150 r->connection->unexpected_eof = 0; | 148 r->connection->unexpected_eof = 0; |
151 | 149 |
150 r->keepalive = 1; | |
152 r->lingering_close = 1; | 151 r->lingering_close = 1; |
153 r->keepalive = 0; | |
154 | 152 |
155 #if 1 | 153 #if 1 |
156 r->filter = NGX_HTTP_FILTER_NEED_IN_MEMORY; | 154 r->filter = NGX_HTTP_FILTER_NEED_IN_MEMORY; |
157 #endif | 155 #endif |
158 | 156 |
211 ngx_log_debug(r->connection->log, "cxt: %08x" _ ctx); | 209 ngx_log_debug(r->connection->log, "cxt: %08x" _ ctx); |
212 ngx_log_debug(r->connection->log, "srv_conf: %0x" _ r->srv_conf); | 210 ngx_log_debug(r->connection->log, "srv_conf: %0x" _ r->srv_conf); |
213 ngx_log_debug(r->connection->log, "loc_conf: %0x" _ r->loc_conf); | 211 ngx_log_debug(r->connection->log, "loc_conf: %0x" _ r->loc_conf); |
214 | 212 |
215 /* run translation phase */ | 213 /* run translation phase */ |
216 for (i = 0; ngx_modules[i]; i++) { | 214 |
217 if (ngx_modules[i]->type != NGX_HTTP_MODULE_TYPE) { | 215 h = (ngx_http_handler_pt *) ngx_http_translate_handlers.elts; |
216 for (i = 0; i < ngx_http_translate_handlers.nelts; i++) { | |
217 rc = h[i](r); | |
218 | |
219 if (rc == NGX_DECLINED) { | |
218 continue; | 220 continue; |
219 } | 221 } |
220 | 222 |
221 module = (ngx_http_module_t *) ngx_modules[i]->ctx; | |
222 | |
223 if (module->translate_handler == NULL) { | |
224 continue; | |
225 } | |
226 | |
227 rc = module->translate_handler(r); | |
228 if (rc == NGX_OK) { | 223 if (rc == NGX_OK) { |
229 break; | 224 break; |
230 } | 225 } |
231 | 226 |
232 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { | 227 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { |
233 return ngx_http_special_response(r, rc); | 228 return rc; |
234 } | 229 } |
235 } | 230 } |
236 | 231 |
237 rc = r->handler(r); | 232 return r->handler(r); |
238 | |
239 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { | |
240 return ngx_http_special_response(r, rc); | |
241 } | |
242 | |
243 return rc; | |
244 } | 233 } |
245 | 234 |
246 | 235 |
247 int ngx_http_core_translate_handler(ngx_http_request_t *r) | 236 int ngx_http_core_translate_handler(ngx_http_request_t *r) |
248 { | 237 { |
250 char *buf, *location, *last; | 239 char *buf, *location, *last; |
251 ngx_err_t err; | 240 ngx_err_t err; |
252 ngx_table_elt_t *h; | 241 ngx_table_elt_t *h; |
253 ngx_http_server_name_t *s_name; | 242 ngx_http_server_name_t *s_name; |
254 ngx_http_core_srv_conf_t *scf; | 243 ngx_http_core_srv_conf_t *scf; |
255 ngx_http_core_loc_conf_t **lcf, *loc_conf; | 244 ngx_http_core_loc_conf_t *lcf, **plcf; |
256 | 245 |
257 scf = (ngx_http_core_srv_conf_t *) | 246 scf = (ngx_http_core_srv_conf_t *) |
258 ngx_http_get_module_srv_conf(r, ngx_http_core_module_ctx); | 247 ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
259 | 248 |
260 /* find location config */ | 249 /* find location config */ |
261 lcf = (ngx_http_core_loc_conf_t **) scf->locations.elts; | 250 plcf = (ngx_http_core_loc_conf_t **) scf->locations.elts; |
262 for (i = 0; i < scf->locations.nelts; i++) { | 251 for (i = 0; i < scf->locations.nelts; i++) { |
263 ngx_log_debug(r->connection->log, "trans: %s" _ lcf[i]->name.data); | 252 ngx_log_debug(r->connection->log, "trans: %s" _ plcf[i]->name.data); |
264 if (r->uri.len < lcf[i]->name.len) { | 253 if (r->uri.len < plcf[i]->name.len) { |
265 continue; | 254 continue; |
266 } | 255 } |
267 | 256 |
268 rc = ngx_strncmp(r->uri.data, lcf[i]->name.data, lcf[i]->name.len); | 257 rc = ngx_strncmp(r->uri.data, plcf[i]->name.data, plcf[i]->name.len); |
269 | 258 |
270 if (rc < 0) { | 259 if (rc < 0) { |
271 break; | 260 break; |
272 } | 261 } |
273 | 262 |
274 if (rc == 0) { | 263 if (rc == 0) { |
275 r->loc_conf = lcf[i]->loc_conf; | 264 r->loc_conf = plcf[i]->loc_conf; |
276 } | 265 } |
277 } | 266 } |
278 | 267 |
279 #if 0 | 268 #if 0 |
280 /* STUB */ r->handler = ngx_http_proxy_handler; | 269 /* STUB */ r->handler = ngx_http_proxy_handler; |
284 if (r->uri.data[r->uri.len - 1] == '/') { | 273 if (r->uri.data[r->uri.len - 1] == '/') { |
285 r->handler = ngx_http_core_index_handler; | 274 r->handler = ngx_http_core_index_handler; |
286 return NGX_OK; | 275 return NGX_OK; |
287 } | 276 } |
288 | 277 |
289 loc_conf = (ngx_http_core_loc_conf_t *) | 278 lcf = (ngx_http_core_loc_conf_t *) |
290 ngx_http_get_module_loc_conf(r, ngx_http_core_module_ctx); | 279 ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
291 | 280 |
292 ngx_log_debug(r->connection->log, "doc_root: %08x" _ &loc_conf->doc_root); | 281 ngx_log_debug(r->connection->log, "doc_root: %08x" _ &lcf->doc_root); |
293 | 282 |
294 s_name = (ngx_http_server_name_t *) scf->server_names.elts; | 283 s_name = (ngx_http_server_name_t *) scf->server_names.elts; |
295 | 284 |
296 if (r->port == 0) { | 285 if (r->port == 0) { |
297 #if 0 | 286 #if 0 |
312 } | 301 } |
313 | 302 |
314 port_len = (r->port != 80) ? r->port_name.len : 0; | 303 port_len = (r->port != 80) ? r->port_name.len : 0; |
315 | 304 |
316 /* "+ 7" is "http://" */ | 305 /* "+ 7" is "http://" */ |
317 if (loc_conf->doc_root.len > 7 + s_name[0].name.len + port_len) { | 306 if (lcf->doc_root.len > 7 + s_name[0].name.len + port_len) { |
318 len = loc_conf->doc_root.len; | 307 len = lcf->doc_root.len; |
319 f_offset = 0; | 308 f_offset = 0; |
320 l_offset = len - (7 + s_name[0].name.len + port_len); | 309 l_offset = len - (7 + s_name[0].name.len + port_len); |
321 | 310 |
322 } else { | 311 } else { |
323 len = 7 + s_name[0].name.len + port_len; | 312 len = 7 + s_name[0].name.len + port_len; |
324 f_offset = len - loc_conf->doc_root.len; | 313 f_offset = len - lcf->doc_root.len; |
325 l_offset = 0; | 314 l_offset = 0; |
326 } | 315 } |
327 | 316 |
328 /* "+ 2" is for trailing '/' in redirect and '\0' */ | 317 /* "+ 2" is for trailing '/' in redirect and '\0' */ |
329 len += r->uri.len + 2; | 318 len += r->uri.len + 2; |
332 NGX_HTTP_INTERNAL_SERVER_ERROR); | 321 NGX_HTTP_INTERNAL_SERVER_ERROR); |
333 | 322 |
334 r->file.name.data = buf + f_offset; | 323 r->file.name.data = buf + f_offset; |
335 location = buf + l_offset; | 324 location = buf + l_offset; |
336 | 325 |
337 last = ngx_cpystrn(ngx_cpystrn(r->file.name.data, loc_conf->doc_root.data, | 326 last = ngx_cpystrn(ngx_cpystrn(r->file.name.data, lcf->doc_root.data, |
338 loc_conf->doc_root.len + 1), | 327 lcf->doc_root.len + 1), |
339 r->uri.data, r->uri.len + 1); | 328 r->uri.data, r->uri.len + 1); |
340 | 329 |
341 r->file.name.len = last - r->file.name.data; | 330 r->file.name.len = last - r->file.name.data; |
342 | 331 |
343 ngx_log_debug(r->connection->log, "HTTP filename: '%s'" _ r->file.name.data); | 332 ngx_log_debug(r->connection->log, "HTTP filename: '%s'" _ r->file.name.data); |
344 | 333 |
345 #if (WIN9X) | 334 #if (WIN9X) |
346 | 335 |
347 /* There is no way to open file or directory in Win9X with | 336 /* There is no way to open a file or a directory in Win9X with |
348 one syscall: Win9X has not FILE_FLAG_BACKUP_SEMANTICS flag. | 337 one syscall: Win9X has no FILE_FLAG_BACKUP_SEMANTICS flag. |
349 so we need to check its type before opening */ | 338 so we need to check its type before the opening */ |
350 | 339 |
351 r->file.info.dwFileAttributes = GetFileAttributes(r->file.name.data); | 340 r->file.info.dwFileAttributes = GetFileAttributes(r->file.name.data); |
352 if (r->file.info.dwFileAttributes == INVALID_FILE_ATTRIBUTES) { | 341 if (r->file.info.dwFileAttributes == INVALID_FILE_ATTRIBUTES) { |
353 err = ngx_errno; | 342 err = ngx_errno; |
354 ngx_log_error(NGX_LOG_ERR, r->connection->log, err, | 343 ngx_log_error(NGX_LOG_ERR, r->connection->log, err, |
449 r->headers_out.location = h; | 438 r->headers_out.location = h; |
450 | 439 |
451 return NGX_HTTP_MOVED_PERMANENTLY; | 440 return NGX_HTTP_MOVED_PERMANENTLY; |
452 } | 441 } |
453 | 442 |
454 /* TODO: r->handler = loc_conf->default_handler; */ | 443 /* TODO: r->handler = lcf->default_handler; */ |
455 /* STUB */ r->handler = ngx_http_static_handler; | 444 /* STUB */ r->handler = ngx_http_static_handler; |
456 | 445 |
457 return NGX_OK; | 446 return NGX_OK; |
458 } | 447 } |
459 | 448 |
501 { | 490 { |
502 /* STUB */ | 491 /* STUB */ |
503 | 492 |
504 /* log request */ | 493 /* log request */ |
505 | 494 |
506 return ngx_http_close_request(r); | 495 return ngx_http_close_request(r, 0); |
507 } | 496 } |
508 | 497 |
509 | 498 |
510 int ngx_http_error(ngx_http_request_t *r, int error) | 499 int ngx_http_error(ngx_http_request_t *r, int error) |
511 { | 500 { |
512 /* STUB */ | 501 /* STUB */ |
513 ngx_log_debug(r->connection->log, "http error: %d" _ error); | 502 ngx_log_debug(r->connection->log, "http error: %d" _ error); |
514 | 503 |
515 /* log request */ | 504 /* log request */ |
516 | 505 |
517 ngx_http_special_response(r, error); | 506 ngx_http_special_response_handler(r, error); |
518 return ngx_http_close_request(r); | 507 return ngx_http_close_request(r, 0); |
519 } | 508 } |
520 | 509 |
521 | 510 |
522 int ngx_http_close_request(ngx_http_request_t *r) | 511 int ngx_http_close_request(ngx_http_request_t *r, int error) |
523 { | 512 { |
524 ngx_connection_t *c; | 513 ngx_connection_t *c; |
525 ngx_http_log_ctx_t *ctx; | 514 ngx_http_log_ctx_t *ctx; |
526 | 515 |
527 c = r->connection; | 516 c = r->connection; |
517 if (error) { | |
518 r->headers_out.status = error; | |
519 } | |
528 | 520 |
529 ngx_http_log_handler(r); | 521 ngx_http_log_handler(r); |
530 | 522 |
531 if (r->file.fd != NGX_INVALID_FILE) { | 523 if (r->file.fd != NGX_INVALID_FILE) { |
532 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) { | 524 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) { |
571 | 563 |
572 return ngx_http_handler(r); | 564 return ngx_http_handler(r); |
573 } | 565 } |
574 | 566 |
575 | 567 |
568 static int ngx_http_core_init(ngx_pool_t *pool) | |
569 { | |
570 ngx_http_handler_pt *h; | |
571 | |
572 ngx_test_null(h, ngx_push_array(&ngx_http_translate_handlers), NGX_ERROR); | |
573 | |
574 *h = ngx_http_core_translate_handler; | |
575 | |
576 return NGX_OK; | |
577 } | |
578 | |
579 | |
576 static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy) | 580 static char *ngx_server_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy) |
577 { | 581 { |
578 int i, j; | 582 int i, j; |
579 char *rv; | 583 char *rv; |
580 ngx_http_module_t *module; | 584 ngx_http_module_t *module; |
581 ngx_http_conf_ctx_t *ctx, *prev; | 585 ngx_http_conf_ctx_t *ctx, *prev; |
582 ngx_http_core_srv_conf_t *scf; | 586 ngx_http_core_srv_conf_t *scf; |
583 ngx_http_core_loc_conf_t **lcf; | 587 ngx_http_core_loc_conf_t **plcf; |
584 | 588 |
585 ngx_test_null(ctx, | 589 ngx_test_null(ctx, |
586 ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), | 590 ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), |
587 NGX_CONF_ERROR); | 591 NGX_CONF_ERROR); |
588 | 592 |
602 } | 606 } |
603 | 607 |
604 module = (ngx_http_module_t *) ngx_modules[i]->ctx; | 608 module = (ngx_http_module_t *) ngx_modules[i]->ctx; |
605 | 609 |
606 if (module->create_srv_conf) { | 610 if (module->create_srv_conf) { |
607 ngx_test_null(ctx->srv_conf[module->index], | 611 ngx_test_null(ctx->srv_conf[ngx_modules[i]->index], |
608 module->create_srv_conf(cf->pool), | 612 module->create_srv_conf(cf->pool), |
609 NGX_CONF_ERROR); | 613 NGX_CONF_ERROR); |
610 } | 614 } |
611 | 615 |
612 if (module->create_loc_conf) { | 616 if (module->create_loc_conf) { |
613 ngx_test_null(ctx->loc_conf[module->index], | 617 ngx_test_null(ctx->loc_conf[ngx_modules[i]->index], |
614 module->create_loc_conf(cf->pool), | 618 module->create_loc_conf(cf->pool), |
615 NGX_CONF_ERROR); | 619 NGX_CONF_ERROR); |
616 } | 620 } |
617 } | 621 } |
618 | 622 |
623 | 627 |
624 if (rv != NGX_CONF_OK) | 628 if (rv != NGX_CONF_OK) |
625 return rv; | 629 return rv; |
626 | 630 |
627 | 631 |
628 scf = ctx->srv_conf[ngx_http_core_module_ctx.index]; | 632 scf = ctx->srv_conf[ngx_http_core_module.index]; |
629 scf->ctx = ctx; | 633 scf->ctx = ctx; |
630 | 634 |
631 lcf = (ngx_http_core_loc_conf_t **)scf->locations.elts; | 635 plcf = (ngx_http_core_loc_conf_t **)scf->locations.elts; |
632 | 636 |
633 for (i = 0; ngx_modules[i]; i++) { | 637 for (i = 0; ngx_modules[i]; i++) { |
634 if (ngx_modules[i]->type != NGX_HTTP_MODULE_TYPE) { | 638 if (ngx_modules[i]->type != NGX_HTTP_MODULE_TYPE) { |
635 continue; | 639 continue; |
636 } | 640 } |
637 | 641 |
638 module = (ngx_http_module_t *) ngx_modules[i]->ctx; | 642 module = (ngx_http_module_t *) ngx_modules[i]->ctx; |
639 | 643 |
640 if (module->init_srv_conf) { | 644 if (module->init_srv_conf) { |
641 if (module->init_srv_conf(cf->pool, | 645 if (module->init_srv_conf(cf->pool, |
642 ctx->srv_conf[module->index]) | 646 ctx->srv_conf[ngx_modules[i]->index]) |
643 == NGX_CONF_ERROR) { | 647 == NGX_CONF_ERROR) { |
644 return NGX_CONF_ERROR; | 648 return NGX_CONF_ERROR; |
645 } | 649 } |
646 } | 650 } |
647 | 651 |
648 if (module->merge_loc_conf) { | 652 if (module->merge_loc_conf) { |
649 if (module->merge_loc_conf(cf->pool, | 653 if (module->merge_loc_conf(cf->pool, |
650 prev->loc_conf[module->index], | 654 prev->loc_conf[ngx_modules[i]->index], |
651 ctx->loc_conf[module->index]) | 655 ctx->loc_conf[ngx_modules[i]->index]) |
652 == NGX_CONF_ERROR) { | 656 == NGX_CONF_ERROR) { |
653 return NGX_CONF_ERROR; | 657 return NGX_CONF_ERROR; |
654 } | 658 } |
655 | 659 |
656 for (j = 0; j < scf->locations.nelts; j++) { | 660 for (j = 0; j < scf->locations.nelts; j++) { |
657 if (module->merge_loc_conf(cf->pool, | 661 if (module->merge_loc_conf(cf->pool, |
658 ctx->loc_conf[module->index], | 662 ctx->loc_conf[ngx_modules[i]->index], |
659 lcf[j]->loc_conf[module->index]) | 663 plcf[j]->loc_conf[ngx_modules[i]->index]) |
660 == NGX_CONF_ERROR) { | 664 == NGX_CONF_ERROR) { |
661 return NGX_CONF_ERROR; | 665 return NGX_CONF_ERROR; |
662 } | 666 } |
663 } | 667 } |
664 } | 668 } |
674 char *rv; | 678 char *rv; |
675 ngx_str_t *location; | 679 ngx_str_t *location; |
676 ngx_http_module_t *module; | 680 ngx_http_module_t *module; |
677 ngx_http_conf_ctx_t *ctx, *prev; | 681 ngx_http_conf_ctx_t *ctx, *prev; |
678 ngx_http_core_srv_conf_t *scf; | 682 ngx_http_core_srv_conf_t *scf; |
679 ngx_http_core_loc_conf_t *lcf, **loc; | 683 ngx_http_core_loc_conf_t *lcf, **plcf; |
680 | 684 |
681 ngx_test_null(ctx, | 685 ngx_test_null(ctx, |
682 ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), | 686 ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), |
683 NGX_CONF_ERROR); | 687 NGX_CONF_ERROR); |
684 | 688 |
695 } | 699 } |
696 | 700 |
697 module = (ngx_http_module_t *) ngx_modules[i]->ctx; | 701 module = (ngx_http_module_t *) ngx_modules[i]->ctx; |
698 | 702 |
699 if (module->create_loc_conf) { | 703 if (module->create_loc_conf) { |
700 ngx_test_null(ctx->loc_conf[module->index], | 704 ngx_test_null(ctx->loc_conf[ngx_modules[i]->index], |
701 module->create_loc_conf(cf->pool), | 705 module->create_loc_conf(cf->pool), |
702 NGX_CONF_ERROR); | 706 NGX_CONF_ERROR); |
703 } | 707 } |
704 } | 708 } |
705 | 709 |
710 lcf->name.data = location[1].data; | 714 lcf->name.data = location[1].data; |
711 lcf->loc_conf = ctx->loc_conf; | 715 lcf->loc_conf = ctx->loc_conf; |
712 | 716 |
713 scf = (ngx_http_core_srv_conf_t *) | 717 scf = (ngx_http_core_srv_conf_t *) |
714 ctx->srv_conf[ngx_http_core_module.index]; | 718 ctx->srv_conf[ngx_http_core_module.index]; |
715 ngx_test_null(loc, ngx_push_array(&scf->locations), NGX_CONF_ERROR); | 719 ngx_test_null(plcf, ngx_push_array(&scf->locations), NGX_CONF_ERROR); |
716 *loc = lcf; | 720 *plcf = lcf; |
717 | 721 |
718 cf->ctx = ctx; | 722 cf->ctx = ctx; |
719 rv = ngx_conf_parse(cf, NULL); | 723 rv = ngx_conf_parse(cf, NULL); |
720 cf->ctx = prev; | 724 cf->ctx = prev; |
721 | 725 |
787 NGX_CONF_ERROR); | 791 NGX_CONF_ERROR); |
788 | 792 |
789 lcf->doc_root.len = 4; | 793 lcf->doc_root.len = 4; |
790 lcf->doc_root.data = "html"; | 794 lcf->doc_root.data = "html"; |
791 | 795 |
792 lcf->send_timeout = 10; | 796 lcf->send_timeout = 10000; |
793 lcf->discarded_buffer_size = 1500; | 797 lcf->discarded_buffer_size = 1500; |
794 lcf->lingering_time = 30000; | 798 lcf->lingering_time = 30000; |
795 lcf->lingering_timeout = 5000; | 799 lcf->lingering_timeout = 5000; |
796 | 800 |
797 /* | 801 /* |