summaryrefslogtreecommitdiffhomepage
path: root/src/http/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/modules')
-rw-r--r--src/http/modules/ngx_http_access_handler.c5
-rw-r--r--src/http/modules/ngx_http_charset_filter.c6
-rw-r--r--src/http/modules/ngx_http_index_handler.c51
-rw-r--r--src/http/modules/ngx_http_rewrite_handler.c4
-rw-r--r--src/http/modules/ngx_http_ssl_module.c6
-rw-r--r--src/http/modules/ngx_http_static_handler.c6
-rw-r--r--src/http/modules/ngx_http_status_handler.c4
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_handler.c6
8 files changed, 60 insertions, 28 deletions
diff --git a/src/http/modules/ngx_http_access_handler.c b/src/http/modules/ngx_http_access_handler.c
index a57526ef2..b6fdeab09 100644
--- a/src/http/modules/ngx_http_access_handler.c
+++ b/src/http/modules/ngx_http_access_handler.c
@@ -190,13 +190,8 @@ static char *ngx_http_access_merge_loc_conf(ngx_conf_t *cf,
static ngx_int_t ngx_http_access_init(ngx_cycle_t *cycle)
{
ngx_http_handler_pt *h;
- ngx_http_conf_ctx_t *ctx;
ngx_http_core_main_conf_t *cmcf;
-#if 0
- ctx = (ngx_http_conf_ctx_t *) cycle->conf_ctx[ngx_http_module.index];
- cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
-#endif
cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
h = ngx_push_array(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers);
diff --git a/src/http/modules/ngx_http_charset_filter.c b/src/http/modules/ngx_http_charset_filter.c
index d7ce88e10..662f0b28a 100644
--- a/src/http/modules/ngx_http_charset_filter.c
+++ b/src/http/modules/ngx_http_charset_filter.c
@@ -363,7 +363,6 @@ static char *ngx_http_set_charset_slot(ngx_conf_t *cf, ngx_command_t *cmd,
ngx_int_t *cp;
ngx_str_t *value;
ngx_http_charset_t *charset;
- ngx_http_conf_ctx_t *ctx;
ngx_http_charset_main_conf_t *mcf;
cp = (ngx_int_t *) (p + cmd->offset);
@@ -372,8 +371,9 @@ static char *ngx_http_set_charset_slot(ngx_conf_t *cf, ngx_command_t *cmd,
return "is duplicate";
}
- ctx = cf->ctx;
- mcf = ctx->main_conf[ngx_http_charset_filter_module.ctx_index];
+ mcf = ngx_http_conf_get_module_main_conf(cf,
+ ngx_http_charset_filter_module);
+
value = cf->args->elts;
*cp = ngx_http_add_charset(&mcf->charsets, &value[1]);
diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c
index 80e4d19d9..ddd889404 100644
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -98,6 +98,7 @@ ngx_module_t ngx_http_index_module = {
ngx_int_t ngx_http_index_handler(ngx_http_request_t *r)
{
u_char *name;
+ size_t len;
ngx_fd_t fd;
ngx_int_t rc;
ngx_str_t *index;
@@ -160,6 +161,7 @@ ngx_int_t ngx_http_index_handler(ngx_http_request_t *r)
#endif
+#if 0
ctx->path.data = ngx_palloc(r->pool, clcf->root.len + r->uri.len
+ ilcf->max_index_len
- clcf->alias * clcf->name.len);
@@ -169,9 +171,35 @@ ngx_int_t ngx_http_index_handler(ngx_http_request_t *r)
ctx->redirect.data = ngx_cpymem(ctx->path.data, clcf->root.data,
clcf->root.len);
+#endif
if (clcf->alias) {
- ctx->last = ngx_cpystrn(ctx->redirect.data,
+ if (clcf->root.len > clcf->name.len) {
+ ctx->path.data = ngx_palloc(r->pool, clcf->root.len
+ + r->uri.len
+ - clcf->name.len
+ + ilcf->max_index_len);
+ if (ctx->path.data == NULL) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ ctx->redirect.data = ctx->path.data + clcf->root.len + 1
+ - clcf->name.len;
+
+ } else {
+ ctx->redirect.data = ngx_palloc(r->pool, r->uri.len
+ + ilcf->max_index_len);
+ if (ctx->redirect.data == NULL) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ ctx->path.data = ctx->redirect.data + clcf->name.len
+ - clcf->root.len;
+ }
+
+ ngx_memcpy(ctx->path.data, clcf->root.data, clcf->root.len);
+
+ ctx->last = ngx_cpystrn(ctx->path.data + clcf->root.len,
r->uri.data + clcf->name.len,
r->uri.len + 1 - clcf->name.len);
@@ -185,6 +213,15 @@ ngx_int_t ngx_http_index_handler(ngx_http_request_t *r)
}
} else {
+ ctx->path.data = ngx_palloc(r->pool, clcf->root.len + r->uri.len
+ + ilcf->max_index_len);
+ if (ctx->path.data == NULL) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ }
+
+ ctx->redirect.data = ngx_cpymem(ctx->path.data, clcf->root.data,
+ clcf->root.len);
+
ctx->last = ngx_cpystrn(ctx->redirect.data, r->uri.data,
r->uri.len + 1);
}
@@ -255,8 +292,14 @@ ngx_int_t ngx_http_index_handler(ngx_http_request_t *r)
ctx->redirect.data = index[ctx->index].data;
} else {
- ctx->redirect.len = r->uri.len + index[ctx->index].len;
+ if (clcf->alias) {
+ ngx_memcpy(ctx->redirect.data, clcf->name.data, clcf->name.len);
+ }
+
+ ctx->redirect.len = r->uri.len + index[ctx->index].len
+ - clcf->alias * clcf->name.len;
r->file.name.len = clcf->root.len + r->uri.len
+ - clcf->alias * clcf->name.len
+ index[ctx->index].len;
}
@@ -364,11 +407,9 @@ static ngx_int_t ngx_http_index_error(ngx_http_request_t *r,
static ngx_int_t ngx_http_index_init(ngx_cycle_t *cycle)
{
ngx_http_handler_pt *h;
- ngx_http_conf_ctx_t *ctx;
ngx_http_core_main_conf_t *cmcf;
- ctx = (ngx_http_conf_ctx_t *) cycle->conf_ctx[ngx_http_module.index];
- cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
+ cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
h = ngx_push_array(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
if (h == NULL) {
diff --git a/src/http/modules/ngx_http_rewrite_handler.c b/src/http/modules/ngx_http_rewrite_handler.c
index 7d36b131a..5c25c89e4 100644
--- a/src/http/modules/ngx_http_rewrite_handler.c
+++ b/src/http/modules/ngx_http_rewrite_handler.c
@@ -369,11 +369,9 @@ static char *ngx_http_rewrite_rule(ngx_conf_t *cf, ngx_command_t *cmd,
static ngx_int_t ngx_http_rewrite_init(ngx_cycle_t *cycle)
{
ngx_http_handler_pt *h;
- ngx_http_conf_ctx_t *ctx;
ngx_http_core_main_conf_t *cmcf;
- ctx = (ngx_http_conf_ctx_t *) cycle->conf_ctx[ngx_http_module.index];
- cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
+ cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
h = ngx_push_array(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers);
if (h == NULL) {
diff --git a/src/http/modules/ngx_http_ssl_module.c b/src/http/modules/ngx_http_ssl_module.c
index 3a8b863a2..699bd8f6a 100644
--- a/src/http/modules/ngx_http_ssl_module.c
+++ b/src/http/modules/ngx_http_ssl_module.c
@@ -105,7 +105,8 @@ static char *ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf,
return NGX_CONF_ERROR;
}
- if (SSL_CTX_use_certificate_file(conf->ssl_ctx, conf->certificate.data,
+ if (SSL_CTX_use_certificate_file(conf->ssl_ctx,
+ (char *) conf->certificate.data,
SSL_FILETYPE_PEM) == 0) {
ngx_ssl_error(NGX_LOG_EMERG, cf->log, 0,
"SSL_CTX_use_certificate_file(\"%s\") failed",
@@ -113,7 +114,8 @@ static char *ngx_http_ssl_merge_srv_conf(ngx_conf_t *cf,
return NGX_CONF_ERROR;
}
- if (SSL_CTX_use_PrivateKey_file(conf->ssl_ctx, conf->certificate_key.data,
+ if (SSL_CTX_use_PrivateKey_file(conf->ssl_ctx,
+ (char *) conf->certificate_key.data,
SSL_FILETYPE_PEM) == 0) {
ngx_ssl_error(NGX_LOG_EMERG, cf->log, 0,
"SSL_CTX_use_PrivateKey_file(\"%s\") failed",
diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c
index 9c11c7eb1..bc32cc539 100644
--- a/src/http/modules/ngx_http_static_handler.c
+++ b/src/http/modules/ngx_http_static_handler.c
@@ -537,11 +537,9 @@ static char *ngx_http_static_merge_loc_conf(ngx_conf_t *cf,
static ngx_int_t ngx_http_static_init(ngx_cycle_t *cycle)
{
ngx_http_handler_pt *h;
- ngx_http_conf_ctx_t *ctx;
ngx_http_core_main_conf_t *cmcf;
-
- ctx = (ngx_http_conf_ctx_t *) cycle->conf_ctx[ngx_http_module.index];
- cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
+
+ cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module);
h = ngx_push_array(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
if (h == NULL) {
diff --git a/src/http/modules/ngx_http_status_handler.c b/src/http/modules/ngx_http_status_handler.c
index adf9d0285..57d7aa077 100644
--- a/src/http/modules/ngx_http_status_handler.c
+++ b/src/http/modules/ngx_http_status_handler.c
@@ -299,11 +299,9 @@ static ngx_int_t ngx_http_status(ngx_http_status_ctx_t *ctx)
static char *ngx_http_set_status(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
- ngx_http_conf_ctx_t *ctx;
ngx_http_core_loc_conf_t *clcf;
- ctx = cf->ctx;
- clcf = ctx->loc_conf[ngx_http_core_module.ctx_index];
+ clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
clcf->handler = ngx_http_status_handler;
return NGX_CONF_OK;
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index 4f8fbda67..711aad2f4 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -1062,7 +1062,6 @@ static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd,
in_addr_t addr;
ngx_str_t *value;
struct hostent *h;
- ngx_http_conf_ctx_t *ctx;
ngx_http_core_loc_conf_t *clcf;
@@ -1177,10 +1176,11 @@ static char *ngx_http_proxy_set_pass(ngx_conf_t *cf, ngx_command_t *cmd,
lcf->upstream->port_text.len + 1);
}
- ctx = cf->ctx;
- clcf = ctx->loc_conf[ngx_http_core_module.ctx_index];
+ clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
+
lcf->upstream->location = &clcf->name;
clcf->handler = ngx_http_proxy_handler;
+
if (clcf->name.data[clcf->name.len - 1] == '/') {
clcf->auto_redirect = 1;
}