comparison src/http/ngx_http_request_body.c @ 278:704622b2528a NGINX_0_5_9

nginx 0.5.9 *) Change: now the ngx_http_memcached_module uses the $memcached_key variable value as a key. *) Feature: the $memcached_key variable. *) Feature: the "clean" parameter in the "client_body_in_file_only" directive. *) Feature: the "env" directive. *) Feature: the "sendfile" directive is available inside the "if" block. *) Feature: now on failure of the writing to access nginx logs a message to error_log, but not more often than once a minute. *) Bugfix: the "access_log off" directive did not always turn off the logging.
author Igor Sysoev <http://sysoev.ru>
date Thu, 25 Jan 2007 00:00:00 +0300
parents c5c2b2883984
children 5bef04fc3fd5
comparison
equal deleted inserted replaced
277:b3aec7787b8e 278:704622b2528a
12 12
13 static void ngx_http_read_client_request_body_handler(ngx_http_request_t *r); 13 static void ngx_http_read_client_request_body_handler(ngx_http_request_t *r);
14 static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r); 14 static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r);
15 static ngx_int_t ngx_http_write_request_body(ngx_http_request_t *r, 15 static ngx_int_t ngx_http_write_request_body(ngx_http_request_t *r,
16 ngx_chain_t *body); 16 ngx_chain_t *body);
17 static void ngx_http_finalize_request_body(ngx_http_request_t *r, ngx_int_t rc);
18 static void ngx_http_read_discarded_body_handler(ngx_http_request_t *r); 17 static void ngx_http_read_discarded_body_handler(ngx_http_request_t *r);
19 static ngx_int_t ngx_http_read_discarded_body(ngx_http_request_t *r); 18 static ngx_int_t ngx_http_read_discarded_body(ngx_http_request_t *r);
20 19
21 20
22 /* 21 /*
70 tf->path = clcf->client_body_temp_path; 69 tf->path = clcf->client_body_temp_path;
71 tf->pool = r->pool; 70 tf->pool = r->pool;
72 tf->warn = "a client request body is buffered to a temporary file"; 71 tf->warn = "a client request body is buffered to a temporary file";
73 tf->log_level = r->request_body_file_log_level; 72 tf->log_level = r->request_body_file_log_level;
74 tf->persistent = r->request_body_in_persistent_file; 73 tf->persistent = r->request_body_in_persistent_file;
74 tf->clean = r->request_body_in_clean_file;
75 75
76 if (r->request_body_file_group_access) { 76 if (r->request_body_file_group_access) {
77 tf->access = 0660; 77 tf->access = 0660;
78 } 78 }
79 79
80 rb->temp_file = tf; 80 rb->temp_file = tf;
81 81
82 if (ngx_create_temp_file(&tf->file, tf->path, tf->pool, 82 if (ngx_create_temp_file(&tf->file, tf->path, tf->pool,
83 tf->persistent, tf->access) 83 tf->persistent, tf->clean, tf->access)
84 != NGX_OK) 84 != NGX_OK)
85 { 85 {
86 return NGX_HTTP_INTERNAL_SERVER_ERROR; 86 return NGX_HTTP_INTERNAL_SERVER_ERROR;
87 } 87 }
88 } 88 }
236 { 236 {
237 ngx_int_t rc; 237 ngx_int_t rc;
238 238
239 if (r->connection->read->timedout) { 239 if (r->connection->read->timedout) {
240 r->connection->timedout = 1; 240 r->connection->timedout = 1;
241 ngx_http_finalize_request_body(r, NGX_HTTP_REQUEST_TIME_OUT); 241 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_TIME_OUT);
242 return; 242 return;
243 } 243 }
244 244
245 rc = ngx_http_do_read_client_request_body(r); 245 rc = ngx_http_do_read_client_request_body(r);
246 246
247 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { 247 if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
248 ngx_http_finalize_request_body(r, rc); 248 ngx_http_finalize_request(r, rc);
249 } 249 }
250 } 250 }
251 251
252 252
253 static ngx_int_t 253 static ngx_int_t
398 tf->path = clcf->client_body_temp_path; 398 tf->path = clcf->client_body_temp_path;
399 tf->pool = r->pool; 399 tf->pool = r->pool;
400 tf->warn = "a client request body is buffered to a temporary file"; 400 tf->warn = "a client request body is buffered to a temporary file";
401 tf->log_level = r->request_body_file_log_level; 401 tf->log_level = r->request_body_file_log_level;
402 tf->persistent = r->request_body_in_persistent_file; 402 tf->persistent = r->request_body_in_persistent_file;
403 tf->clean = r->request_body_in_clean_file;
403 404
404 if (r->request_body_file_group_access) { 405 if (r->request_body_file_group_access) {
405 tf->access = 0660; 406 tf->access = 0660;
406 } 407 }
407 408
417 } 418 }
418 419
419 rb->temp_file->offset += n; 420 rb->temp_file->offset += n;
420 421
421 return NGX_OK; 422 return NGX_OK;
422 }
423
424
425 static void
426 ngx_http_finalize_request_body(ngx_http_request_t *r, ngx_int_t rc)
427 {
428 if (r->request_body->temp_file
429 && r->request_body_in_persistent_file
430 && r->request_body_delete_incomplete_file)
431 {
432 if (ngx_delete_file(r->request_body->temp_file->file.name.data)
433 == NGX_FILE_ERROR)
434 {
435 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
436 ngx_delete_file_n " \"%s\" failed",
437 r->request_body->temp_file->file.name.data);
438 }
439 }
440
441 ngx_http_finalize_request(r, rc);
442 } 423 }
443 424
444 425
445 ngx_int_t 426 ngx_int_t
446 ngx_http_discard_body(ngx_http_request_t *r) 427 ngx_http_discard_body(ngx_http_request_t *r)