comparison src/http/ngx_http_request_body.c @ 256:2e9c57a5e50a NGINX_0_4_13

nginx 0.4.13 *) Feature: the "proxy_pass" directive may be used inside the "limit_except" block. *) Feature: the "limit_except" directive supports all WebDAV methods. *) Bugfix: if the "add_before_body" directive was used without the "add_after_body" directive, then an response did not transferred complete. *) Bugfix: a large request body did not receive if the epoll method and the deferred accept() were used. *) Bugfix: a charset could not be set for ngx_http_autoindex_module responses; bug appeared in 0.3.50. *) Bugfix: the "[alert] zero size buf" error when FastCGI server was used; *) Bugfix: the --group= configuration parameter was ignored. Thanks to Thomas Moschny. *) Bugfix: the 50th subrequest in SSI response did not work; bug appeared in 0.3.50.
author Igor Sysoev <http://sysoev.ru>
date Wed, 15 Nov 2006 00:00:00 +0300
parents a528ae0fe909
children c5c2b2883984
comparison
equal deleted inserted replaced
255:a13bad126e69 256:2e9c57a5e50a
263 263
264 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, 264 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
265 "http read client request body"); 265 "http read client request body");
266 266
267 for ( ;; ) { 267 for ( ;; ) {
268 if (rb->buf->last == rb->buf->end) { 268 for ( ;; ) {
269 269 if (rb->buf->last == rb->buf->end) {
270 if (ngx_http_write_request_body(r, rb->to_write) != NGX_OK) { 270
271 return NGX_HTTP_INTERNAL_SERVER_ERROR; 271 if (ngx_http_write_request_body(r, rb->to_write) != NGX_OK) {
272 } 272 return NGX_HTTP_INTERNAL_SERVER_ERROR;
273 273 }
274 rb->to_write = rb->bufs->next ? rb->bufs->next : rb->bufs; 274
275 rb->buf->last = rb->buf->start; 275 rb->to_write = rb->bufs->next ? rb->bufs->next : rb->bufs;
276 } 276 rb->buf->last = rb->buf->start;
277 277 }
278 size = rb->buf->end - rb->buf->last; 278
279 279 size = rb->buf->end - rb->buf->last;
280 if ((off_t) size > rb->rest) { 280
281 size = (size_t) rb->rest; 281 if ((off_t) size > rb->rest) {
282 } 282 size = (size_t) rb->rest;
283 283 }
284 n = c->recv(c, rb->buf->last, size); 284
285 n = c->recv(c, rb->buf->last, size);
286
287 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
288 "http client request body recv %z", n);
289
290 if (n == NGX_AGAIN) {
291 break;
292 }
293
294 if (n == 0) {
295 ngx_log_error(NGX_LOG_INFO, c->log, 0,
296 "client closed prematurely connection");
297 }
298
299 if (n == 0 || n == NGX_ERROR) {
300 c->error = 1;
301 return NGX_HTTP_BAD_REQUEST;
302 }
303
304 rb->buf->last += n;
305 rb->rest -= n;
306 r->request_length += n;
307
308 if (rb->rest == 0) {
309 break;
310 }
311
312 if (rb->buf->last < rb->buf->end) {
313 break;
314 }
315 }
285 316
286 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, 317 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
287 "http client request body recv %z", n); 318 "http client request body rest %uz", rb->rest);
288
289 if (n == NGX_AGAIN) {
290 break;
291 }
292
293 if (n == 0) {
294 ngx_log_error(NGX_LOG_INFO, c->log, 0,
295 "client closed prematurely connection");
296 }
297
298 if (n == 0 || n == NGX_ERROR) {
299 c->error = 1;
300 return NGX_HTTP_BAD_REQUEST;
301 }
302
303 rb->buf->last += n;
304 rb->rest -= n;
305 r->request_length += n;
306 319
307 if (rb->rest == 0) { 320 if (rb->rest == 0) {
308 break; 321 break;
309 } 322 }
310 323
311 if (rb->buf->last < rb->buf->end) { 324 if (!c->read->ready) {
312 break; 325 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
313 } 326 ngx_add_timer(c->read, clcf->client_body_timeout);
314 } 327
315 328 if (ngx_handle_read_event(c->read, 0) == NGX_ERROR) {
316 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, 329 return NGX_HTTP_INTERNAL_SERVER_ERROR;
317 "http client request body rest %uz", rb->rest); 330 }
318 331
319 if (rb->rest) { 332 return NGX_AGAIN;
320 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 333 }
321 ngx_add_timer(c->read, clcf->client_body_timeout);
322
323 if (ngx_handle_read_event(c->read, 0) == NGX_ERROR) {
324 return NGX_HTTP_INTERNAL_SERVER_ERROR;
325 }
326
327 return NGX_AGAIN;
328 } 334 }
329 335
330 if (c->read->timer_set) { 336 if (c->read->timer_set) {
331 ngx_del_timer(c->read); 337 ngx_del_timer(c->read);
332 } 338 }