comparison src/http/ngx_http_core_module.c @ 411:4765ded59eaa

nginx-0.0.10-2004-08-30-23:24:51 import
author Igor Sysoev <igor@sysoev.ru>
date Mon, 30 Aug 2004 19:24:51 +0000
parents 37b5381fb6d8
children 3c56e834be46
comparison
equal deleted inserted replaced
410:48b9ad5ca1fc 411:4765ded59eaa
12 12
13 13
14 static void ngx_http_phase_event_handler(ngx_event_t *rev); 14 static void ngx_http_phase_event_handler(ngx_event_t *rev);
15 static void ngx_http_run_phases(ngx_http_request_t *r); 15 static void ngx_http_run_phases(ngx_http_request_t *r);
16 static ngx_int_t ngx_http_find_location(ngx_http_request_t *r, 16 static ngx_int_t ngx_http_find_location(ngx_http_request_t *r,
17 ngx_array_t *locations); 17 ngx_array_t *locations, size_t len);
18 18
19 static void *ngx_http_core_create_main_conf(ngx_conf_t *cf); 19 static void *ngx_http_core_create_main_conf(ngx_conf_t *cf);
20 static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf); 20 static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf);
21 static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf); 21 static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf);
22 static char *ngx_http_core_merge_srv_conf(ngx_conf_t *cf, 22 static char *ngx_http_core_merge_srv_conf(ngx_conf_t *cf,
484 ngx_http_core_loc_conf_t *clcf; 484 ngx_http_core_loc_conf_t *clcf;
485 ngx_http_core_srv_conf_t *cscf; 485 ngx_http_core_srv_conf_t *cscf;
486 486
487 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); 487 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
488 488
489 rc = ngx_http_find_location(r, &cscf->locations); 489 rc = ngx_http_find_location(r, &cscf->locations, 0);
490 490
491 if (rc == NGX_HTTP_INTERNAL_SERVER_ERROR) { 491 if (rc == NGX_HTTP_INTERNAL_SERVER_ERROR) {
492 return rc; 492 return rc;
493 } 493 }
494 494
549 return NGX_OK; 549 return NGX_OK;
550 } 550 }
551 551
552 552
553 static ngx_int_t ngx_http_find_location(ngx_http_request_t *r, 553 static ngx_int_t ngx_http_find_location(ngx_http_request_t *r,
554 ngx_array_t *locations) 554 ngx_array_t *locations, size_t len)
555 { 555 {
556 ngx_int_t n, rc; 556 ngx_int_t n, rc;
557 ngx_uint_t i, found; 557 ngx_uint_t i, found;
558 ngx_http_core_loc_conf_t *clcf, **clcfp; 558 ngx_http_core_loc_conf_t *clcf, **clcfp;
559 559
602 if (clcfp[i]->exact_match && r->uri.len == clcfp[i]->name.len) { 602 if (clcfp[i]->exact_match && r->uri.len == clcfp[i]->name.len) {
603 r->loc_conf = clcfp[i]->loc_conf; 603 r->loc_conf = clcfp[i]->loc_conf;
604 return NGX_HTTP_LOCATION_EXACT; 604 return NGX_HTTP_LOCATION_EXACT;
605 } 605 }
606 606
607 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 607 if (len > clcfp[i]->name.len) {
608
609 #if 0
610 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
611 "p:%d c:%d", clcf->name.len, clcfp[i]->name.len);
612 #endif
613
614 if (clcf->name.len > clcfp[i]->name.len) {
615 /* the previous match is longer */ 608 /* the previous match is longer */
616 break; 609 break;
617 } 610 }
618 611
619 r->loc_conf = clcfp[i]->loc_conf; 612 r->loc_conf = clcfp[i]->loc_conf;
623 616
624 if (found) { 617 if (found) {
625 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 618 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
626 619
627 if (clcf->locations.nelts) { 620 if (clcf->locations.nelts) {
628 rc = ngx_http_find_location(r, &clcf->locations); 621 rc = ngx_http_find_location(r, &clcf->locations, len);
629 622
630 if (rc != NGX_OK) { 623 if (rc != NGX_OK) {
631 return rc; 624 return rc;
632 } 625 }
633 } 626 }
1627 value = cf->args->elts; 1620 value = cf->args->elts;
1628 1621
1629 lcf->alias = alias; 1622 lcf->alias = alias;
1630 lcf->root = value[1]; 1623 lcf->root = value[1];
1631 1624
1625 if (!alias && lcf->root.data[lcf->root.len - 1] == '/') {
1626 lcf->root.len--;
1627 }
1628
1632 return NGX_CONF_OK; 1629 return NGX_CONF_OK;
1633 } 1630 }
1634 1631
1635 1632
1636 static char *ngx_set_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 1633 static char *ngx_set_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)