Klaus Demo nginx / e5d4020
discard request body in cycle Igor Sysoev 13 years ago
1 changed file(s) with 30 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
500500 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
501501 "http read discarded body");
502502
503 if (r->headers_in.content_length_n == 0) {
504 return NGX_OK;
505 }
506
507 size = (r->headers_in.content_length_n > NGX_HTTP_DISCARD_BUFFER_SIZE) ?
508 NGX_HTTP_DISCARD_BUFFER_SIZE:
509 (size_t) r->headers_in.content_length_n;
510
511 n = r->connection->recv(r->connection, buffer, size);
512
513 if (n == NGX_ERROR) {
514
515 r->connection->error = 1;
516
517 /*
518 * if a client request body is discarded then we already set
519 * some HTTP response code for client and we can ignore the error
520 */
521
522 return NGX_OK;
523 }
524
525 if (n == NGX_AGAIN) {
526 return NGX_AGAIN;
527 }
528
529 r->headers_in.content_length_n -= n;
503 do {
504 if (r->headers_in.content_length_n == 0) {
505 return NGX_OK;
506 }
507
508 size = (r->headers_in.content_length_n > NGX_HTTP_DISCARD_BUFFER_SIZE) ?
509 NGX_HTTP_DISCARD_BUFFER_SIZE:
510 (size_t) r->headers_in.content_length_n;
511
512 n = r->connection->recv(r->connection, buffer, size);
513
514 if (n == NGX_ERROR) {
515
516 r->connection->error = 1;
517
518 /*
519 * if a client request body is discarded then we already set
520 * some HTTP response code for client and we can ignore the error
521 */
522
523 return NGX_OK;
524 }
525
526 if (n == NGX_AGAIN) {
527 return NGX_AGAIN;
528 }
529
530 r->headers_in.content_length_n -= n;
531
532 } while (r->connection->read->ready);
530533
531534 return NGX_OK;
532535 }