aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_core_module.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2003-11-18 21:34:08 +0000
committerIgor Sysoev <igor@sysoev.ru>2003-11-18 21:34:08 +0000
commit1b138ed141c0bdb0c9944c1ae70e53682ed2d035 (patch)
treec5b4cabecced530570f4a2d6a93cc7d5fc8e044e /src/http/ngx_http_core_module.c
parent222a2adf40eb25ff613c251f15032f1e39d7f609 (diff)
downloadnginx-1b138ed141c0bdb0c9944c1ae70e53682ed2d035.tar.gz
nginx-1b138ed141c0bdb0c9944c1ae70e53682ed2d035.zip
nginx-0.0.1-2003-11-19-00:34:08 import
Diffstat (limited to 'src/http/ngx_http_core_module.c')
-rw-r--r--src/http/ngx_http_core_module.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 529f2ee27..f4f5d4f3c 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -369,16 +369,27 @@ static void ngx_http_run_phases(ngx_http_request_t *r)
int ngx_http_find_location_config(ngx_http_request_t *r)
{
int i, rc;
+ ngx_str_t *auto_redirect;
ngx_http_core_loc_conf_t *clcf, **clcfp;
ngx_http_core_srv_conf_t *cscf;
cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
+ auto_redirect = NULL;
clcfp = cscf->locations.elts;
for (i = 0; i < cscf->locations.nelts; i++) {
#if 0
ngx_log_debug(r->connection->log, "trans: %s" _ clcfp[i]->name.data);
#endif
+ if (clcfp[i]->auto_redirect
+ && r->uri.len == clcfp[i]->name.len - 1
+ && ngx_strncmp(r->uri.data, clcfp[i]->name.data,
+ clcfp[i]->name.len - 1) == 0)
+ {
+ auto_redirect = &clcfp[i]->name;
+ continue;
+ }
+
if (r->uri.len < clcfp[i]->name.len) {
continue;
}
@@ -386,6 +397,7 @@ ngx_log_debug(r->connection->log, "trans: %s" _ clcfp[i]->name.data);
rc = ngx_strncmp(r->uri.data, clcfp[i]->name.data, clcfp[i]->name.len);
if (rc < 0) {
+ /* locations are lexicographically sorted */
break;
}
@@ -406,6 +418,22 @@ ngx_log_debug(r->connection->log, "trans: %s" _ clcfp[i]->name.data);
r->sendfile = 1;
}
+ if (auto_redirect) {
+ if (!(r->headers_out.location =
+ ngx_http_add_header(&r->headers_out, ngx_http_headers_out)))
+ {
+ 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;
+ }
+
if (clcf->handler) {
/*
* if the location already has content handler then skip