Mercurial > hg > nginx
comparison src/http/ngx_http_core_module.c @ 216:f1d0e5f09c1e
nginx-0.0.1-2003-12-25-23:26:58 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 25 Dec 2003 20:26:58 +0000 |
parents | fd9fecc4193f |
children | 05592fd7a436 |
comparison
equal
deleted
inserted
replaced
215:5adc2b75f8a5 | 216:f1d0e5f09c1e |
---|---|
467 "find location: %s\"%s\"", | 467 "find location: %s\"%s\"", |
468 clcfp[i]->exact_match ? "= " : | 468 clcfp[i]->exact_match ? "= " : |
469 clcfp[i]->regex ? "~ " : "", | 469 clcfp[i]->regex ? "~ " : "", |
470 clcfp[i]->name.data); | 470 clcfp[i]->name.data); |
471 | 471 |
472 rc = ngx_regex_exec(clcfp[i]->regex, &r->uri); | 472 rc = ngx_regex_exec(clcfp[i]->regex, &r->uri, NULL, 0); |
473 | 473 |
474 if (rc == NGX_DECLINED) { | 474 if (rc == NGX_DECLINED) { |
475 continue; | 475 continue; |
476 } | 476 } |
477 | 477 |
611 ngx_http_close_request(r, 0); | 611 ngx_http_close_request(r, 0); |
612 return NGX_OK; | 612 return NGX_OK; |
613 } | 613 } |
614 | 614 |
615 | 615 |
616 ngx_int_t ngx_http_set_exten(ngx_http_request_t *r) | |
617 { | |
618 ngx_int_t i; | |
619 | |
620 r->exten.len = 0; | |
621 r->exten.data = NULL; | |
622 | |
623 for (i = r->uri.len - 1; i > 1; i--) { | |
624 if (r->uri.data[i] == '.' && r->uri.data[i - 1] != '/') { | |
625 r->exten.len = r->uri.len - i - 1; | |
626 | |
627 if (r->exten.len > 0) { | |
628 if (!(r->exten.data = ngx_palloc(r->pool, r->exten.len + 1))) { | |
629 return NGX_ERROR; | |
630 } | |
631 | |
632 ngx_cpystrn(r->exten.data, &r->uri.data[i + 1], | |
633 r->exten.len + 1); | |
634 } | |
635 | |
636 break; | |
637 | |
638 } else if (r->uri.data[i] == '/') { | |
639 break; | |
640 } | |
641 } | |
642 | |
643 return NGX_OK; | |
644 } | |
645 | |
646 | |
616 int ngx_http_internal_redirect(ngx_http_request_t *r, | 647 int ngx_http_internal_redirect(ngx_http_request_t *r, |
617 ngx_str_t *uri, ngx_str_t *args) | 648 ngx_str_t *uri, ngx_str_t *args) |
618 { | 649 { |
619 int i; | |
620 | |
621 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 650 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
622 "internal redirect: \"%s\"", uri->data); | 651 "internal redirect: \"%s\"", uri->data); |
623 | 652 |
624 r->uri.len = uri->len; | 653 r->uri.len = uri->len; |
625 r->uri.data = uri->data; | 654 r->uri.data = uri->data; |
627 if (args) { | 656 if (args) { |
628 r->args.len = args->len; | 657 r->args.len = args->len; |
629 r->args.data = args->data; | 658 r->args.data = args->data; |
630 } | 659 } |
631 | 660 |
632 r->exten.len = 0; | 661 if (ngx_http_set_exten(r) != NGX_OK) { |
633 r->exten.data = NULL; | 662 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
634 | |
635 for (i = uri->len - 1; i > 1; i--) { | |
636 if (uri->data[i] == '.' && uri->data[i - 1] != '/') { | |
637 r->exten.len = uri->len - i - 1; | |
638 | |
639 if (r->exten.len > 0) { | |
640 ngx_test_null(r->exten.data, | |
641 ngx_palloc(r->pool, r->exten.len + 1), | |
642 NGX_HTTP_INTERNAL_SERVER_ERROR); | |
643 | |
644 ngx_cpystrn(r->exten.data, &uri->data[i + 1], r->exten.len + 1); | |
645 } | |
646 | |
647 break; | |
648 | |
649 } else if (uri->data[i] == '/') { | |
650 break; | |
651 } | |
652 } | 663 } |
653 | 664 |
654 if (r->err_ctx) { | 665 if (r->err_ctx) { |
655 | 666 |
656 /* allocate the new modules contexts */ | 667 /* allocate the new modules contexts */ |
870 } | 881 } |
871 | 882 |
872 clcf = ctx->loc_conf[ngx_http_core_module.ctx_index]; | 883 clcf = ctx->loc_conf[ngx_http_core_module.ctx_index]; |
873 clcf->loc_conf = ctx->loc_conf; | 884 clcf->loc_conf = ctx->loc_conf; |
874 | 885 |
875 value = (ngx_str_t *) cf->args->elts; | 886 value = cf->args->elts; |
876 | 887 |
877 if (cf->args->nelts == 3) { | 888 if (cf->args->nelts == 3) { |
878 if (value[1].len == 1 && value[1].data[0] == '=') { | 889 if (value[1].len == 1 && value[1].data[0] == '=') { |
879 clcf->name.len = value[2].len; | 890 clcf->name.len = value[2].len; |
880 clcf->name.data = value[2].data; | 891 clcf->name.data = value[2].data; |
896 if (clcf->regex == NULL) { | 907 if (clcf->regex == NULL) { |
897 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%s", err.data); | 908 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%s", err.data); |
898 return NGX_CONF_ERROR; | 909 return NGX_CONF_ERROR; |
899 } | 910 } |
900 | 911 |
901 clcf->name.len = value[2].len; | 912 clcf->name = value[2]; |
902 clcf->name.data = value[2].data; | |
903 #else | 913 #else |
904 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 914 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
905 "the using of the regex \"%s\" " | 915 "the using of the regex \"%s\" " |
906 "requires PCRE library", | 916 "requires PCRE library", |
907 value[2].data); | 917 value[2].data); |