aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_core_module.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-12-14 20:10:27 +0000
committerIgor Sysoev <igor@sysoev.ru>2003-12-14 20:10:27 +0000
commitdc867cd0fed793f86ce2b460f8c2ad069ddec1b5 (patch)
tree507db64a0a152c9ec99785a3ea887154ec4873b3 /src/http/ngx_http_core_module.c
parent2b58fbf045acee349c323de8f50501f94c41c04d (diff)
downloadnginx-dc867cd0fed793f86ce2b460f8c2ad069ddec1b5.tar.gz
nginx-dc867cd0fed793f86ce2b460f8c2ad069ddec1b5.zip
nginx-0.0.1-2003-12-14-23:10:27 import
Diffstat (limited to 'src/http/ngx_http_core_module.c')
-rw-r--r--src/http/ngx_http_core_module.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 2f5c92345..6d20fdf7f 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -407,14 +407,17 @@ int ngx_http_find_location_config(ngx_http_request_t *r)
clcfp = cscf->locations.elts;
for (i = 0; i < cscf->locations.nelts; i++) {
-#if 1
-ngx_log_debug(r->connection->log, "trans: %s: %d" _
- clcfp[i]->name.data _ clcfp[i]->exact_match);
-#endif
+#if (HAVE_PCRE)
if (clcfp[i]->regex) {
break;
}
+#endif
+
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "find location: %s\"%s\"",
+ clcfp[i]->exact_match ? "= " : "",
+ clcfp[i]->name.data);
if (clcfp[i]->auto_redirect
&& r->uri.len == clcfp[i]->name.len - 1
@@ -449,20 +452,23 @@ ngx_log_debug(r->connection->log, "trans: %s: %d" _
}
}
+#if (HAVE_PCRE)
+
if (!exact && !auto_redirect) {
/* regex matches */
for (/* void */; i < cscf->locations.nelts; i++) {
-#if 1
-ngx_log_debug(r->connection->log, "trans: %s: %d" _
- clcfp[i]->name.data _ clcfp[i]->exact_match);
-#endif
-
if (!clcfp[i]->regex) {
continue;
}
+ ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "find location: %s\"%s\"",
+ clcfp[i]->exact_match ? "= " :
+ clcfp[i]->regex ? "~ " : "",
+ clcfp[i]->name.data);
+
rc = ngx_regex_exec(clcfp[i]->regex, &r->uri);
if (rc == NGX_DECLINED) {
@@ -488,6 +494,8 @@ ngx_log_debug(r->connection->log, "trans: %s: %d" _
}
}
+#endif /* HAVE_PCRE */
+
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
if (!(ngx_io.flags & NGX_IO_SENDFILE) || !clcf->sendfile) {
@@ -504,10 +512,6 @@ ngx_log_debug(r->connection->log, "trans: %s: %d" _
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
-#if 0
- r->headers_out.location->key.len = 8;
- r->headers_out.location->key.data = "Location";
-#endif
r->headers_out.location->value = *auto_redirect;
return NGX_HTTP_MOVED_PERMANENTLY;
@@ -614,7 +618,8 @@ int ngx_http_internal_redirect(ngx_http_request_t *r,
{
int i;
- ngx_log_debug(r->connection->log, "internal redirect: '%s'" _ uri->data);
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "internal redirect: \"%s\"", uri->data);
r->uri.len = uri->len;
r->uri.data = uri->data;
@@ -798,6 +803,8 @@ static int ngx_cmp_locations(const void *one, const void *two)
ngx_int_t rc;
+#if (HAVE_PCRE)
+
if (first->regex && !second->regex) {
/* shift regex matches to the end */
return 1;
@@ -808,6 +815,8 @@ static int ngx_cmp_locations(const void *one, const void *two)
return 0;
}
+#endif
+
rc = ngx_strcmp(first->name.data, second->name.data);
if (rc == 0 && second->exact_match) {
@@ -876,6 +885,7 @@ static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
&& value[1].data[0] == '~'
&& value[1].data[1] == '*'))
{
+#if (HAVE_PCRE)
err.len = NGX_MAX_CONF_ERRSTR;
err.data = errstr;
@@ -890,6 +900,13 @@ static char *ngx_location_block(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
clcf->name.len = value[2].len;
clcf->name.data = value[2].data;
+#else
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "the using of the regex \"%s\" "
+ "requires PCRE library",
+ value[2].data);
+ return NGX_CONF_ERROR;
+#endif
} else {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,