comparison src/http/ngx_http_request_body.c @ 5563:3b7463b08747 stable-1.4

Fixed "zero size buf in output" alerts. If a request had an empty request body (with Content-Length: 0), and there were preread data available (e.g., due to a pipelined request in the buffer), the "zero size buf in output" alert might be logged while proxying the request to an upstream. Similar alerts appeared with client_body_in_file_only if a request had an empty request body.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 04 Jan 2014 03:32:22 +0400
parents 4196ea50004a
children 8a2261c59f3b
comparison
equal deleted inserted replaced
5562:4196ea50004a 5563:3b7463b08747
148 if (ngx_http_write_request_body(r) != NGX_OK) { 148 if (ngx_http_write_request_body(r) != NGX_OK) {
149 rc = NGX_HTTP_INTERNAL_SERVER_ERROR; 149 rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
150 goto done; 150 goto done;
151 } 151 }
152 152
153 cl = ngx_chain_get_free_buf(r->pool, &rb->free); 153 if (rb->temp_file->file.offset != 0) {
154 if (cl == NULL) { 154
155 rc = NGX_HTTP_INTERNAL_SERVER_ERROR; 155 cl = ngx_chain_get_free_buf(r->pool, &rb->free);
156 goto done; 156 if (cl == NULL) {
157 } 157 rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
158 158 goto done;
159 b = cl->buf; 159 }
160 160
161 ngx_memzero(b, sizeof(ngx_buf_t)); 161 b = cl->buf;
162 162
163 b->in_file = 1; 163 ngx_memzero(b, sizeof(ngx_buf_t));
164 b->file_last = rb->temp_file->file.offset; 164
165 b->file = &rb->temp_file->file; 165 b->in_file = 1;
166 166 b->file_last = rb->temp_file->file.offset;
167 rb->bufs = cl; 167 b->file = &rb->temp_file->file;
168
169 rb->bufs = cl;
170
171 } else {
172 rb->bufs = NULL;
173 }
168 } 174 }
169 175
170 post_handler(r); 176 post_handler(r);
171 177
172 return NGX_OK; 178 return NGX_OK;
373 379
374 if (ngx_http_write_request_body(r) != NGX_OK) { 380 if (ngx_http_write_request_body(r) != NGX_OK) {
375 return NGX_HTTP_INTERNAL_SERVER_ERROR; 381 return NGX_HTTP_INTERNAL_SERVER_ERROR;
376 } 382 }
377 383
378 cl = ngx_chain_get_free_buf(r->pool, &rb->free); 384 if (rb->temp_file->file.offset != 0) {
379 if (cl == NULL) { 385
380 return NGX_HTTP_INTERNAL_SERVER_ERROR; 386 cl = ngx_chain_get_free_buf(r->pool, &rb->free);
381 } 387 if (cl == NULL) {
382 388 return NGX_HTTP_INTERNAL_SERVER_ERROR;
383 b = cl->buf; 389 }
384 390
385 ngx_memzero(b, sizeof(ngx_buf_t)); 391 b = cl->buf;
386 392
387 b->in_file = 1; 393 ngx_memzero(b, sizeof(ngx_buf_t));
388 b->file_last = rb->temp_file->file.offset; 394
389 b->file = &rb->temp_file->file; 395 b->in_file = 1;
390 396 b->file_last = rb->temp_file->file.offset;
391 rb->bufs = cl; 397 b->file = &rb->temp_file->file;
398
399 rb->bufs = cl;
400
401 } else {
402 rb->bufs = NULL;
403 }
392 } 404 }
393 405
394 r->read_event_handler = ngx_http_block_reading; 406 r->read_event_handler = ngx_http_block_reading;
395 407
396 rb->post_handler(r); 408 rb->post_handler(r);
840 852
841 out = NULL; 853 out = NULL;
842 ll = &out; 854 ll = &out;
843 855
844 for (cl = in; cl; cl = cl->next) { 856 for (cl = in; cl; cl = cl->next) {
857
858 if (rb->rest == 0) {
859 break;
860 }
845 861
846 tl = ngx_chain_get_free_buf(r->pool, &rb->free); 862 tl = ngx_chain_get_free_buf(r->pool, &rb->free);
847 if (tl == NULL) { 863 if (tl == NULL) {
848 return NGX_HTTP_INTERNAL_SERVER_ERROR; 864 return NGX_HTTP_INTERNAL_SERVER_ERROR;
849 } 865 }