summaryrefslogtreecommitdiffhomepage
path: root/src/http
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2007-01-25 08:45:04 +0000
committerIgor Sysoev <igor@sysoev.ru>2007-01-25 08:45:04 +0000
commitcd5b99a0450ea5c6bdf8a40d607760d93b1c1190 (patch)
tree90561613d8ae962ab9f5f96c652ffe315b030f83 /src/http
parent3a58cc90b5f7cd10e8dcb50abddb8d1218b32746 (diff)
downloadnginx-cd5b99a0450ea5c6bdf8a40d607760d93b1c1190.tar.gz
nginx-cd5b99a0450ea5c6bdf8a40d607760d93b1c1190.tar.bz2
undo "client_body_in_file_only any"
and introduce "client_body_in_file_only clean" introduce ngx_pool_delete_file() to not break a possible third-party ngx_pool_cleanup_file() usage that may lead to an removal of the useful files delete unnecessary ngx_http_finalize_request_body()
Diffstat (limited to 'src/http')
-rw-r--r--src/http/modules/ngx_http_dav_module.c2
-rw-r--r--src/http/modules/perl/nginx.xs2
-rw-r--r--src/http/ngx_http_core_module.c10
-rw-r--r--src/http/ngx_http_request.h2
-rw-r--r--src/http/ngx_http_request_body.c48
5 files changed, 14 insertions, 50 deletions
diff --git a/src/http/modules/ngx_http_dav_module.c b/src/http/modules/ngx_http_dav_module.c
index 277a5bfc9..5a2f0cacb 100644
--- a/src/http/modules/ngx_http_dav_module.c
+++ b/src/http/modules/ngx_http_dav_module.c
@@ -135,7 +135,7 @@ ngx_http_dav_handler(ngx_http_request_t *r)
r->request_body_in_file_only = 1;
r->request_body_in_persistent_file = 1;
- r->request_body_delete_incomplete_file = 1;
+ r->request_body_in_clean_file = 1;
r->request_body_file_group_access = 1;
r->request_body_file_log_level = 0;
diff --git a/src/http/modules/perl/nginx.xs b/src/http/modules/perl/nginx.xs
index f13ce0f46..421fa7e8e 100644
--- a/src/http/modules/perl/nginx.xs
+++ b/src/http/modules/perl/nginx.xs
@@ -363,7 +363,7 @@ has_request_body(r, next)
r->request_body_in_single_buf = 1;
r->request_body_in_persistent_file = 1;
- r->request_body_delete_incomplete_file = 1;
+ r->request_body_in_clean_file = 1;
if (r->request_body_in_file_only) {
r->request_body_file_log_level = 0;
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 63efec865..c35ccacda 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -25,7 +25,7 @@ typedef struct {
#define NGX_HTTP_REQUEST_BODY_FILE_OFF 0
#define NGX_HTTP_REQUEST_BODY_FILE_ON 1
-#define NGX_HTTP_REQUEST_BODY_FILE_ANY 2
+#define NGX_HTTP_REQUEST_BODY_FILE_CLEAN 2
static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r,
@@ -82,7 +82,7 @@ static ngx_conf_deprecated_t ngx_conf_deprecated_optimize_host_names = {
static ngx_conf_enum_t ngx_http_core_request_body_in_file[] = {
{ ngx_string("off"), NGX_HTTP_REQUEST_BODY_FILE_OFF },
{ ngx_string("on"), NGX_HTTP_REQUEST_BODY_FILE_ON },
- { ngx_string("any"), NGX_HTTP_REQUEST_BODY_FILE_ANY },
+ { ngx_string("clean"), NGX_HTTP_REQUEST_BODY_FILE_CLEAN },
{ ngx_null_string, 0 }
};
@@ -890,12 +890,10 @@ ngx_http_update_location_config(ngx_http_request_t *r)
if (clcf->client_body_in_file_only) {
r->request_body_in_file_only = 1;
r->request_body_in_persistent_file = 1;
+ r->request_body_in_clean_file =
+ clcf->client_body_in_file_only == NGX_HTTP_REQUEST_BODY_FILE_CLEAN;
r->request_body_file_log_level = NGX_LOG_NOTICE;
- if (clcf->client_body_in_file_only == NGX_HTTP_REQUEST_BODY_FILE_ON) {
- r->request_body_delete_incomplete_file = 1;
- }
-
} else {
r->request_body_file_log_level = NGX_LOG_WARN;
}
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
index 0c7f5cb5f..787b36155 100644
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -409,7 +409,7 @@ struct ngx_http_request_s {
unsigned request_body_in_single_buf:1;
unsigned request_body_in_file_only:1;
unsigned request_body_in_persistent_file:1;
- unsigned request_body_delete_incomplete_file:1;
+ unsigned request_body_in_clean_file:1;
unsigned request_body_file_group_access:1;
unsigned request_body_file_log_level:3;
diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c
index 22076f635..16d60a00b 100644
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -14,7 +14,6 @@ static void ngx_http_read_client_request_body_handler(ngx_http_request_t *r);
static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r);
static ngx_int_t ngx_http_write_request_body(ngx_http_request_t *r,
ngx_chain_t *body);
-static void ngx_http_finalize_request_body(ngx_http_request_t *r, ngx_int_t rc);
static void ngx_http_read_discarded_body_handler(ngx_http_request_t *r);
static ngx_int_t ngx_http_read_discarded_body(ngx_http_request_t *r);
@@ -32,7 +31,6 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
{
size_t preread;
ssize_t size;
- ngx_int_t rc;
ngx_buf_t *b;
ngx_chain_t *cl, **next;
ngx_temp_file_t *tf;
@@ -73,6 +71,7 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
tf->warn = "a client request body is buffered to a temporary file";
tf->log_level = r->request_body_file_log_level;
tf->persistent = r->request_body_in_persistent_file;
+ tf->clean = r->request_body_in_clean_file;
if (r->request_body_file_group_access) {
tf->access = 0660;
@@ -81,7 +80,7 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
rb->temp_file = tf;
if (ngx_create_temp_file(&tf->file, tf->path, tf->pool,
- tf->persistent, tf->access)
+ tf->persistent, tf->clean, tf->access)
!= NGX_OK)
{
return NGX_HTTP_INTERNAL_SERVER_ERROR;
@@ -168,14 +167,7 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
r->read_event_handler = ngx_http_read_client_request_body_handler;
- rc = ngx_http_do_read_client_request_body(r);
-
- if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
- ngx_http_finalize_request_body(r, rc);
- return NGX_DONE;
- }
-
- return rc;
+ return ngx_http_do_read_client_request_body(r);
}
next = &rb->bufs->next;
@@ -235,14 +227,7 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
r->read_event_handler = ngx_http_read_client_request_body_handler;
- rc = ngx_http_do_read_client_request_body(r);
-
- if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
- ngx_http_finalize_request_body(r, rc);
- return NGX_DONE;
- }
-
- return rc;
+ return ngx_http_do_read_client_request_body(r);
}
@@ -253,14 +238,14 @@ ngx_http_read_client_request_body_handler(ngx_http_request_t *r)
if (r->connection->read->timedout) {
r->connection->timedout = 1;
- ngx_http_finalize_request_body(r, NGX_HTTP_REQUEST_TIME_OUT);
+ ngx_http_finalize_request(r, NGX_HTTP_REQUEST_TIME_OUT);
return;
}
rc = ngx_http_do_read_client_request_body(r);
if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
- ngx_http_finalize_request_body(r, rc);
+ ngx_http_finalize_request(r, rc);
}
}
@@ -415,6 +400,7 @@ ngx_http_write_request_body(ngx_http_request_t *r, ngx_chain_t *body)
tf->warn = "a client request body is buffered to a temporary file";
tf->log_level = r->request_body_file_log_level;
tf->persistent = r->request_body_in_persistent_file;
+ tf->clean = r->request_body_in_clean_file;
if (r->request_body_file_group_access) {
tf->access = 0660;
@@ -437,26 +423,6 @@ ngx_http_write_request_body(ngx_http_request_t *r, ngx_chain_t *body)
}
-static void
-ngx_http_finalize_request_body(ngx_http_request_t *r, ngx_int_t rc)
-{
- if (r->request_body->temp_file
- && r->request_body_in_persistent_file
- && r->request_body_delete_incomplete_file)
- {
- if (ngx_delete_file(r->request_body->temp_file->file.name.data)
- == NGX_FILE_ERROR)
- {
- ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
- ngx_delete_file_n " \"%s\" failed",
- r->request_body->temp_file->file.name.data);
- }
- }
-
- ngx_http_finalize_request(r, rc);
-}
-
-
ngx_int_t
ngx_http_discard_body(ngx_http_request_t *r)
{