aboutsummaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
Diffstat (limited to 'src/http')
-rw-r--r--src/http/modules/ngx_http_charset_filter_module.c39
-rw-r--r--src/http/modules/ngx_http_proxy_module.c22
-rw-r--r--src/http/modules/perl/ngx_http_perl_module.c38
-rw-r--r--src/http/ngx_http_core_module.c1
-rw-r--r--src/http/ngx_http_request.c1
-rw-r--r--src/http/ngx_http_script.c4
-rw-r--r--src/http/ngx_http_upstream.c4
7 files changed, 79 insertions, 30 deletions
diff --git a/src/http/modules/ngx_http_charset_filter_module.c b/src/http/modules/ngx_http_charset_filter_module.c
index 3c9e01b3e..c7aa14cfb 100644
--- a/src/http/modules/ngx_http_charset_filter_module.c
+++ b/src/http/modules/ngx_http_charset_filter_module.c
@@ -154,7 +154,7 @@ ngx_http_charset_header_filter(ngx_http_request_t *r)
ngx_uint_t i;
ngx_http_charset_t *charsets;
ngx_http_charset_ctx_t *ctx;
- ngx_http_charset_loc_conf_t *lcf;
+ ngx_http_charset_loc_conf_t *lcf, *mlcf;
ngx_http_charset_main_conf_t *mcf;
mcf = ngx_http_get_module_main_conf(r, ngx_http_charset_filter_module);
@@ -162,9 +162,9 @@ ngx_http_charset_header_filter(ngx_http_request_t *r)
ctx = ngx_http_get_module_ctx(r->main, ngx_http_charset_filter_module);
if (ctx == NULL) {
- lcf = ngx_http_get_module_loc_conf(r->main,
- ngx_http_charset_filter_module);
- charset = lcf->charset;
+ mlcf = ngx_http_get_module_loc_conf(r->main,
+ ngx_http_charset_filter_module);
+ charset = mlcf->charset;
if (charset == NGX_HTTP_NO_CHARSET) {
return ngx_http_next_header_filter(r);
@@ -174,18 +174,29 @@ ngx_http_charset_header_filter(ngx_http_request_t *r)
charset = ctx->charset;
}
- if (r->headers_out.content_type.len == 0) {
- return ngx_http_next_header_filter(r);
- }
+ charsets = mcf->charsets.elts;
- if (ngx_strncasecmp(r->headers_out.content_type.data, "text/", 5) != 0
- && ngx_strncasecmp(r->headers_out.content_type.data,
- "application/x-javascript", 24) != 0)
- {
- return ngx_http_next_header_filter(r);
- }
+ if (r == r->main) {
+ if (r->headers_out.content_type.len == 0) {
+ return ngx_http_next_header_filter(r);
+ }
- charsets = mcf->charsets.elts;
+ if (ngx_strncasecmp(r->headers_out.content_type.data, "text/", 5) != 0
+ && ngx_strncasecmp(r->headers_out.content_type.data,
+ "application/x-javascript", 24) != 0)
+ {
+ return ngx_http_next_header_filter(r);
+ }
+
+ } else {
+ if (r->headers_out.content_type.len == 0) {
+ mlcf = ngx_http_get_module_loc_conf(r->main,
+ ngx_http_charset_filter_module);
+ source_charset = mlcf->source_charset;
+
+ goto found;
+ }
+ }
lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module);
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c
index f5fb9184b..31a4355e5 100644
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -1349,7 +1349,9 @@ ngx_http_proxy_rewrite_redirect_text(ngx_http_request_t *r, ngx_table_elt_t *h,
p = ngx_copy(p, h->value.data, prefix);
- p = ngx_copy(p, pr->replacement.text.data, pr->replacement.text.len);
+ if (pr->replacement.text.len) {
+ p = ngx_copy(p, pr->replacement.text.data, pr->replacement.text.len);
+ }
ngx_memcpy(p, h->value.data + prefix + pr->redirect.len,
h->value.len - pr->redirect.len - prefix);
@@ -1694,7 +1696,14 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
pr->handler = ngx_http_proxy_rewrite_redirect_text;
pr->redirect = conf->upstream.url;
- pr->replacement.text = conf->upstream.location;
+
+ if (conf->upstream.uri.len) {
+ pr->replacement.text = conf->upstream.location;
+
+ } else {
+ pr->replacement.text.len = 0;
+ pr->replacement.text.data = NULL;
+ }
}
}
@@ -2263,7 +2272,14 @@ ngx_http_proxy_redirect(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
pr->handler = ngx_http_proxy_rewrite_redirect_text;
pr->redirect = plcf->upstream.url;
- pr->replacement.text = plcf->upstream.location;
+
+ if (plcf->upstream.uri.len) {
+ pr->replacement.text = plcf->upstream.location;
+
+ } else {
+ pr->replacement.text.len = 0;
+ pr->replacement.text.data = NULL;
+ }
return NGX_CONF_OK;
}
diff --git a/src/http/modules/perl/ngx_http_perl_module.c b/src/http/modules/perl/ngx_http_perl_module.c
index 975c727c8..91a9c85ca 100644
--- a/src/http/modules/perl/ngx_http_perl_module.c
+++ b/src/http/modules/perl/ngx_http_perl_module.c
@@ -34,6 +34,12 @@ typedef struct {
} ngx_http_perl_variable_t;
+typedef struct {
+ SV *sv;
+ PerlInterpreter *perl;
+} ngx_http_perl_cleanup_t;
+
+
#if (NGX_HTTP_SSI)
static ngx_int_t ngx_http_perl_ssi(ngx_http_request_t *r,
ngx_http_ssi_ctx_t *ssi_ctx, ngx_str_t **params);
@@ -51,7 +57,7 @@ static char *ngx_http_perl_init_interpreter(ngx_conf_t *cf,
static PerlInterpreter *
ngx_http_perl_create_interpreter(ngx_http_perl_main_conf_t *pmcf,
ngx_log_t *log);
-static ngx_int_t ngx_http_perl_run_requires(ngx_array_t *requires,
+static ngx_int_t ngx_http_perl_run_requires(pTHX_ ngx_array_t *requires,
ngx_log_t *log);
static ngx_int_t ngx_http_perl_call_handler(pTHX_ ngx_http_request_t *r,
SV *sub, ngx_str_t **args, ngx_str_t *handler, ngx_str_t *rv);
@@ -478,7 +484,7 @@ static char *
ngx_http_perl_init_interpreter(ngx_conf_t *cf, ngx_http_perl_main_conf_t *pmcf)
{
#if (NGX_HAVE_PERL_CLONE || NGX_HAVE_PERL_MULTIPLICITY)
- ngx_pool_cleanup_t *cln;
+ ngx_pool_cleanup_t *cln;
cln = ngx_pool_cleanup_add(cf->pool, 0);
if (cln == NULL) {
@@ -504,7 +510,9 @@ ngx_http_perl_init_interpreter(ngx_conf_t *cf, ngx_http_perl_main_conf_t *pmcf)
#if !(NGX_HAVE_PERL_CLONE || NGX_HAVE_PERL_MULTIPLICITY)
if (perl) {
- if (ngx_http_perl_run_requires(&pmcf->requires, cf->log) != NGX_OK) {
+ if (ngx_http_perl_run_requires(aTHX_ &pmcf->requires, cf->log)
+ != NGX_OK)
+ {
return NGX_CONF_ERROR;
}
@@ -613,7 +621,7 @@ ngx_http_perl_create_interpreter(ngx_http_perl_main_conf_t *pmcf,
goto fail;
}
- if (ngx_http_perl_run_requires(&pmcf->requires, log) != NGX_OK) {
+ if (ngx_http_perl_run_requires(aTHX_ &pmcf->requires, log) != NGX_OK) {
goto fail;
}
@@ -634,7 +642,7 @@ fail:
static ngx_int_t
-ngx_http_perl_run_requires(ngx_array_t *requires, ngx_log_t *log)
+ngx_http_perl_run_requires(pTHX_ ngx_array_t *requires, ngx_log_t *log)
{
char **script;
STRLEN len;
@@ -870,9 +878,11 @@ ngx_http_perl_cleanup_perl(void *data)
static void
ngx_http_perl_cleanup_sv(void *data)
{
- SV *sv = data;
+ ngx_http_perl_cleanup_t *cln = data;
- SvREFCNT_dec(sv);
+ dTHXa(cln->perl);
+
+ SvREFCNT_dec(cln->sv);
}
@@ -967,6 +977,7 @@ ngx_http_perl(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_str_t *value;
ngx_pool_cleanup_t *cln;
+ ngx_http_perl_cleanup_t *pcln;
ngx_http_core_loc_conf_t *clcf;
ngx_http_perl_main_conf_t *pmcf;
@@ -986,7 +997,7 @@ ngx_http_perl(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
}
- cln = ngx_pool_cleanup_add(cf->pool, 0);
+ cln = ngx_pool_cleanup_add(cf->pool, sizeof(ngx_http_perl_cleanup_t));
if (cln == NULL) {
return NGX_CONF_ERROR;
}
@@ -1012,7 +1023,9 @@ ngx_http_perl(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
cln->handler = ngx_http_perl_cleanup_sv;
- cln->data = plcf->sub;
+ pcln = cln->data;
+ pcln->sv = plcf->sub;
+ pcln->perl = pmcf->perl;
clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
clcf->handler = ngx_http_perl_handler;
@@ -1028,6 +1041,7 @@ ngx_http_perl_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_str_t *value;
ngx_pool_cleanup_t *cln;
ngx_http_variable_t *v;
+ ngx_http_perl_cleanup_t *pcln;
ngx_http_perl_variable_t *pv;
ngx_http_perl_main_conf_t *pmcf;
@@ -1065,7 +1079,7 @@ ngx_http_perl_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
}
- cln = ngx_pool_cleanup_add(cf->pool, 0);
+ cln = ngx_pool_cleanup_add(cf->pool, sizeof(ngx_http_perl_cleanup_t));
if (cln == NULL) {
return NGX_CONF_ERROR;
}
@@ -1091,7 +1105,9 @@ ngx_http_perl_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
}
cln->handler = ngx_http_perl_cleanup_sv;
- cln->data = pv->sub;
+ pcln = cln->data;
+ pcln->sv = pv->sub;
+ pcln->perl = pmcf->perl;
v->get_handler = ngx_http_perl_variable;
v->data = (uintptr_t) pv;
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 6cbbf09e7..f08ec458d 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1330,7 +1330,6 @@ ngx_http_internal_redirect(ngx_http_request_t *r,
ngx_http_update_location_config(r);
r->internal = 1;
- r->method = NGX_HTTP_GET;
r->uri_changes--;
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 4f7d24fa5..c606ec81a 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1470,7 +1470,6 @@ ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
|| rc == NGX_HTTP_CREATED
|| rc == NGX_HTTP_NO_CONTENT)
{
-
if (rc == NGX_HTTP_CLOSE) {
ngx_http_close_request(r, rc);
return;
diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c
index 9826ecea5..94793d7e7 100644
--- a/src/http/ngx_http_script.c
+++ b/src/http/ngx_http_script.c
@@ -833,6 +833,10 @@ ngx_http_script_return_code(ngx_http_script_engine_t *e)
e->status = code->status;
+ if (code->status == NGX_HTTP_NO_CONTENT) {
+ e->request->header_only = 1;
+ }
+
e->ip += sizeof(ngx_http_script_return_code_t) - sizeof(uintptr_t);
}
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 4b914abd8..e53d32c1b 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -1160,6 +1160,10 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
r->zero_in_uri = 1;
}
+ if (r->method != NGX_HTTP_HEAD) {
+ r->method = NGX_HTTP_GET;
+ }
+
ngx_http_internal_redirect(r, uri, &args);
return;
}