summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/http/modules/ngx_http_empty_gif_module.c7
-rw-r--r--src/http/modules/ngx_http_rewrite_module.c4
-rw-r--r--src/http/modules/ngx_http_static_module.c2
-rw-r--r--src/http/ngx_http_core_module.c13
-rw-r--r--src/http/ngx_http_core_module.h7
-rw-r--r--src/http/ngx_http_script.c2
-rw-r--r--src/http/ngx_http_special_response.c7
7 files changed, 25 insertions, 17 deletions
diff --git a/src/http/modules/ngx_http_empty_gif_module.c b/src/http/modules/ngx_http_empty_gif_module.c
index a896bd4b6..7cef538ac 100644
--- a/src/http/modules/ngx_http_empty_gif_module.c
+++ b/src/http/modules/ngx_http_empty_gif_module.c
@@ -111,19 +111,12 @@ static ngx_str_t ngx_http_gif_type = ngx_string("image/gif");
static ngx_int_t
ngx_http_empty_gif_handler(ngx_http_request_t *r)
{
- ngx_int_t rc;
ngx_http_complex_value_t cv;
if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD))) {
return NGX_HTTP_NOT_ALLOWED;
}
- rc = ngx_http_discard_request_body(r);
-
- if (rc != NGX_OK) {
- return rc;
- }
-
ngx_memzero(&cv, sizeof(ngx_http_complex_value_t));
cv.value.len = sizeof(ngx_empty_gif);
diff --git a/src/http/modules/ngx_http_rewrite_module.c b/src/http/modules/ngx_http_rewrite_module.c
index 44b5746ea..5164734f2 100644
--- a/src/http/modules/ngx_http_rewrite_module.c
+++ b/src/http/modules/ngx_http_rewrite_module.c
@@ -167,8 +167,8 @@ ngx_http_rewrite_handler(ngx_http_request_t *r)
code(e);
}
- if (e->status == NGX_DECLINED) {
- return NGX_DECLINED;
+ if (e->status < NGX_HTTP_BAD_REQUEST) {
+ return e->status;
}
if (r->err_status == 0) {
diff --git a/src/http/modules/ngx_http_static_module.c b/src/http/modules/ngx_http_static_module.c
index 57b5130d4..cea050a94 100644
--- a/src/http/modules/ngx_http_static_module.c
+++ b/src/http/modules/ngx_http_static_module.c
@@ -139,6 +139,8 @@ ngx_http_static_handler(ngx_http_request_t *r)
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "http dir");
+ ngx_http_clear_location(r);
+
r->headers_out.location = ngx_palloc(r->pool, sizeof(ngx_table_elt_t));
if (r->headers_out.location == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 0255396a0..b94376236 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -983,6 +983,8 @@ ngx_http_core_find_config_phase(ngx_http_request_t *r,
}
if (rc == NGX_DONE) {
+ ngx_http_clear_location(r);
+
r->headers_out.location = ngx_list_push(&r->headers_out.headers);
if (r->headers_out.location == NULL) {
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
@@ -1784,19 +1786,20 @@ ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status,
ngx_buf_t *b;
ngx_chain_t out;
- r->headers_out.status = status;
-
- if (status == NGX_HTTP_NO_CONTENT) {
- r->header_only = 1;
- return ngx_http_send_header(r);
+ if (ngx_http_discard_request_body(r) != NGX_OK) {
+ return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
+ r->headers_out.status = status;
+
if (ngx_http_complex_value(r, cv, &val) != NGX_OK) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
if (status >= NGX_HTTP_MOVED_PERMANENTLY && status <= NGX_HTTP_SEE_OTHER) {
+ ngx_http_clear_location(r);
+
r->headers_out.location = ngx_list_push(&r->headers_out.headers);
if (r->headers_out.location == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index df20b5d3a..d2764fe0d 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -529,5 +529,12 @@ extern ngx_str_t ngx_http_core_get_method;
r->headers_out.last_modified = NULL; \
}
+#define ngx_http_clear_location(r) \
+ \
+ if (r->headers_out.location) { \
+ r->headers_out.location->hash = 0; \
+ r->headers_out.location = NULL; \
+ }
+
#endif /* _NGX_HTTP_CORE_H_INCLUDED_ */
diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c
index a703f0837..6d81b4435 100644
--- a/src/http/ngx_http_script.c
+++ b/src/http/ngx_http_script.c
@@ -1106,6 +1106,8 @@ ngx_http_script_regex_end_code(ngx_http_script_engine_t *e)
"rewritten redirect: \"%V\"", &e->buf);
}
+ ngx_http_clear_location(r);
+
r->headers_out.location = ngx_list_push(&r->headers_out.headers);
if (r->headers_out.location == NULL) {
e->ip = ngx_http_script_exit;
diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
index 2546abceb..d30b781e5 100644
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -421,7 +421,6 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
if (error == NGX_HTTP_CREATED) {
/* 201 */
err = 0;
- r->header_only = 1;
} else if (error == NGX_HTTP_NO_CONTENT) {
/* 204 */
@@ -583,6 +582,8 @@ ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page)
ngx_str_set(&location->key, "Location");
location->value = uri;
+ ngx_http_clear_location(r);
+
r->headers_out.location = location;
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
@@ -636,7 +637,7 @@ ngx_http_send_special_response(ngx_http_request_t *r,
r->headers_out.content_type_lowcase = NULL;
} else {
- r->headers_out.content_length_n = -1;
+ r->headers_out.content_length_n = 0;
}
if (r->headers_out.content_length) {
@@ -654,7 +655,7 @@ ngx_http_send_special_response(ngx_http_request_t *r,
}
if (ngx_http_error_pages[err].len == 0) {
- return NGX_OK;
+ return ngx_http_send_special(r, NGX_HTTP_LAST);
}
b = ngx_calloc_buf(r->pool);