# HG changeset patch # User Igor Sysoev # Date 1186413504 0 # Node ID aa700583b57d0835e7b1ffd0cd948e41f6c7e0ba # Parent 279210f24408cc3d277f40cabe5463c32c277d3a discard request body in cycle diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c --- a/src/http/ngx_http_request_body.c +++ b/src/http/ngx_http_request_body.c @@ -501,33 +501,36 @@ ngx_http_read_discarded_body(ngx_http_re ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http read discarded body"); - if (r->headers_in.content_length_n == 0) { - return NGX_OK; - } + do { + if (r->headers_in.content_length_n == 0) { + return NGX_OK; + } - size = (r->headers_in.content_length_n > NGX_HTTP_DISCARD_BUFFER_SIZE) ? - NGX_HTTP_DISCARD_BUFFER_SIZE: - (size_t) r->headers_in.content_length_n; + size = (r->headers_in.content_length_n > NGX_HTTP_DISCARD_BUFFER_SIZE) ? + NGX_HTTP_DISCARD_BUFFER_SIZE: + (size_t) r->headers_in.content_length_n; - n = r->connection->recv(r->connection, buffer, size); + n = r->connection->recv(r->connection, buffer, size); - if (n == NGX_ERROR) { + if (n == NGX_ERROR) { - r->connection->error = 1; + r->connection->error = 1; - /* - * if a client request body is discarded then we already set - * some HTTP response code for client and we can ignore the error - */ + /* + * if a client request body is discarded then we already set + * some HTTP response code for client and we can ignore the error + */ + + return NGX_OK; + } - return NGX_OK; - } + if (n == NGX_AGAIN) { + return NGX_AGAIN; + } - if (n == NGX_AGAIN) { - return NGX_AGAIN; - } + r->headers_in.content_length_n -= n; - r->headers_in.content_length_n -= n; + } while (r->connection->read->ready); return NGX_OK; }