comparison src/http/ngx_http_request_body.c @ 3162:9140fbb2ab83

fix discarding body
author Igor Sysoev <igor@sysoev.ru>
date Fri, 25 Sep 2009 11:55:33 +0000
parents 98f03cd8d6cc
children b208e383657d
comparison
equal deleted inserted replaced
3161:d430c6ab1c99 3162:9140fbb2ab83
560 u_char buffer[NGX_HTTP_DISCARD_BUFFER_SIZE]; 560 u_char buffer[NGX_HTTP_DISCARD_BUFFER_SIZE];
561 561
562 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 562 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
563 "http read discarded body"); 563 "http read discarded body");
564 564
565 do { 565 for ( ;; ) {
566 if (r->headers_in.content_length_n == 0) { 566 if (r->headers_in.content_length_n == 0) {
567 r->read_event_handler = ngx_http_block_reading; 567 r->read_event_handler = ngx_http_block_reading;
568 return NGX_OK; 568 return NGX_OK;
569 } 569 }
570 570
571 if (!r->connection->read->ready) {
572 return NGX_AGAIN;
573 }
574
571 size = (r->headers_in.content_length_n > NGX_HTTP_DISCARD_BUFFER_SIZE) ? 575 size = (r->headers_in.content_length_n > NGX_HTTP_DISCARD_BUFFER_SIZE) ?
572 NGX_HTTP_DISCARD_BUFFER_SIZE: 576 NGX_HTTP_DISCARD_BUFFER_SIZE:
573 (size_t) r->headers_in.content_length_n; 577 (size_t) r->headers_in.content_length_n;
574 578
575 n = r->connection->recv(r->connection, buffer, size); 579 n = r->connection->recv(r->connection, buffer, size);
586 if (n == 0) { 590 if (n == 0) {
587 return NGX_OK; 591 return NGX_OK;
588 } 592 }
589 593
590 r->headers_in.content_length_n -= n; 594 r->headers_in.content_length_n -= n;
591 595 }
592 } while (r->connection->read->ready);
593
594 return NGX_AGAIN;
595 } 596 }
596 597
597 598
598 static ngx_int_t 599 static ngx_int_t
599 ngx_http_test_expect(ngx_http_request_t *r) 600 ngx_http_test_expect(ngx_http_request_t *r)