comparison src/http/ngx_http_request_body.c @ 4168:795761886688 stable-1.0

Merging r3986, r4006, r4007, r4073: Request body related fixes: *) Always set timer in discard body handler, this fixes the cases when request for static file is redirected by error_page to an SSI page. *) Correctly set body if it's preread and there are extra data. Previously all available data was used as body, resulting in garbage after real body e.g. in case of pipelined requests. Make sure to use only as many bytes as request's Content-Length specifies. *) Fix body with request_body_in_single_buf. If there were preread data and request body was big enough first part of the request body was duplicated. See report here: http://mailman.nginx.org/pipermail/nginx/2011-July/027756.html *) Bugfix: read event was not blocked after reading body. Read event should be blocked after reading body, else undefined behaviour might occur on additional client activity. This fixes segmentation faults observed with proxy_ignore_client_abort set.
author Igor Sysoev <igor@sysoev.ru>
date Fri, 30 Sep 2011 14:36:19 +0000
parents 798a7f1d3b2f
children 4919fb357a5d
comparison
equal deleted inserted replaced
4167:e917fc5eceb7 4168:795761886688
141 141
142 /* the whole request body was pre-read */ 142 /* the whole request body was pre-read */
143 143
144 r->header_in->pos += (size_t) r->headers_in.content_length_n; 144 r->header_in->pos += (size_t) r->headers_in.content_length_n;
145 r->request_length += r->headers_in.content_length_n; 145 r->request_length += r->headers_in.content_length_n;
146 b->last = r->header_in->pos;
146 147
147 if (r->request_body_in_file_only) { 148 if (r->request_body_in_file_only) {
148 if (ngx_http_write_request_body(r, rb->bufs) != NGX_OK) { 149 if (ngx_http_write_request_body(r, rb->bufs) != NGX_OK) {
149 return NGX_HTTP_INTERNAL_SERVER_ERROR; 150 return NGX_HTTP_INTERNAL_SERVER_ERROR;
150 } 151 }
369 } else { 370 } else {
370 rb->bufs->buf = b; 371 rb->bufs->buf = b;
371 } 372 }
372 } 373 }
373 374
374 if (r->request_body_in_file_only && rb->bufs->next) { 375 if (rb->bufs->next
376 && (r->request_body_in_file_only || r->request_body_in_single_buf))
377 {
375 rb->bufs = rb->bufs->next; 378 rb->bufs = rb->bufs->next;
376 } 379 }
380
381 r->read_event_handler = ngx_http_block_reading;
377 382
378 rb->post_handler(r); 383 rb->post_handler(r);
379 384
380 return NGX_OK; 385 return NGX_OK;
381 } 386 }