comparison src/http/ngx_http_request_body.c @ 238:a528ae0fe909 NGINX_0_4_4

nginx 0.4.4 *) Feature: the $scheme variable. *) Feature: the "expires" directive supports the "max" parameter. *) Feature: the "include" directive supports the "*" mask. Thanks to Jonathan Dance. *) Bugfix: the "return" directive always overrode the "error_page" response code redirected by the "error_page" directive. *) Bugfix: a segmentation fault occurred if zero-length body was in PUT method. *) Bugfix: the redirect was changed incorrectly if the variables were used in the "proxy_redirect" directive.
author Igor Sysoev <http://sysoev.ru>
date Mon, 02 Oct 2006 00:00:00 +0400
parents 38e7b94d63ac
children 2e9c57a5e50a
comparison
equal deleted inserted replaced
237:302a8e8b4ae7 238:a528ae0fe909
32 { 32 {
33 size_t preread; 33 size_t preread;
34 ssize_t size; 34 ssize_t size;
35 ngx_buf_t *b; 35 ngx_buf_t *b;
36 ngx_chain_t *cl, **next; 36 ngx_chain_t *cl, **next;
37 ngx_temp_file_t *tf;
37 ngx_http_request_body_t *rb; 38 ngx_http_request_body_t *rb;
38 ngx_http_core_loc_conf_t *clcf; 39 ngx_http_core_loc_conf_t *clcf;
39 40
40 if (r->request_body || r->discard_body) { 41 if (r->request_body || r->discard_body) {
41 post_handler(r); 42 post_handler(r);
47 return NGX_HTTP_INTERNAL_SERVER_ERROR; 48 return NGX_HTTP_INTERNAL_SERVER_ERROR;
48 } 49 }
49 50
50 r->request_body = rb; 51 r->request_body = rb;
51 52
52 if (r->headers_in.content_length_n <= 0) { 53 if (r->headers_in.content_length_n < 0) {
54 post_handler(r);
55 return NGX_OK;
56 }
57
58 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
59
60 if (r->headers_in.content_length_n == 0) {
61
62 if (r->request_body_in_file_only) {
63 tf = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t));
64 if (tf == NULL) {
65 return NGX_HTTP_INTERNAL_SERVER_ERROR;
66 }
67
68 tf->file.fd = NGX_INVALID_FILE;
69 tf->file.log = r->connection->log;
70 tf->path = clcf->client_body_temp_path;
71 tf->pool = r->pool;
72 tf->warn = "a client request body is buffered to a temporary file";
73 tf->log_level = r->request_body_file_log_level;
74 tf->persistent = r->request_body_in_persistent_file;
75
76 if (r->request_body_file_group_access) {
77 tf->mode = 0660;
78 }
79
80 rb->temp_file = tf;
81
82 if (ngx_create_temp_file(&tf->file, tf->path, tf->pool,
83 tf->persistent, tf->mode)
84 != NGX_OK)
85 {
86 return NGX_HTTP_INTERNAL_SERVER_ERROR;
87 }
88 }
89
53 post_handler(r); 90 post_handler(r);
54 return NGX_OK; 91 return NGX_OK;
55 } 92 }
56 93
57 rb->post_handler = post_handler; 94 rb->post_handler = post_handler;
136 } else { 173 } else {
137 b = NULL; 174 b = NULL;
138 rb->rest = r->headers_in.content_length_n; 175 rb->rest = r->headers_in.content_length_n;
139 next = &rb->bufs; 176 next = &rb->bufs;
140 } 177 }
141
142 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
143 178
144 size = clcf->client_body_buffer_size; 179 size = clcf->client_body_buffer_size;
145 size += size >> 2; 180 size += size >> 2;
146 181
147 if (rb->rest < size) { 182 if (rb->rest < size) {