comparison src/http/ngx_http_request_body.c @ 1367:aa700583b57d

discard request body in cycle
author Igor Sysoev <igor@sysoev.ru>
date Mon, 06 Aug 2007 15:18:24 +0000
parents 4e6903652363
children 6254b90eea4b
comparison
equal deleted inserted replaced
1366:279210f24408 1367:aa700583b57d
499 u_char buffer[NGX_HTTP_DISCARD_BUFFER_SIZE]; 499 u_char buffer[NGX_HTTP_DISCARD_BUFFER_SIZE];
500 500
501 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 501 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
502 "http read discarded body"); 502 "http read discarded body");
503 503
504 if (r->headers_in.content_length_n == 0) { 504 do {
505 return NGX_OK; 505 if (r->headers_in.content_length_n == 0) {
506 } 506 return NGX_OK;
507 507 }
508 size = (r->headers_in.content_length_n > NGX_HTTP_DISCARD_BUFFER_SIZE) ? 508
509 NGX_HTTP_DISCARD_BUFFER_SIZE: 509 size = (r->headers_in.content_length_n > NGX_HTTP_DISCARD_BUFFER_SIZE) ?
510 (size_t) r->headers_in.content_length_n; 510 NGX_HTTP_DISCARD_BUFFER_SIZE:
511 511 (size_t) r->headers_in.content_length_n;
512 n = r->connection->recv(r->connection, buffer, size); 512
513 513 n = r->connection->recv(r->connection, buffer, size);
514 if (n == NGX_ERROR) { 514
515 515 if (n == NGX_ERROR) {
516 r->connection->error = 1; 516
517 517 r->connection->error = 1;
518 /* 518
519 * if a client request body is discarded then we already set 519 /*
520 * some HTTP response code for client and we can ignore the error 520 * if a client request body is discarded then we already set
521 */ 521 * some HTTP response code for client and we can ignore the error
522 522 */
523 return NGX_OK; 523
524 } 524 return NGX_OK;
525 525 }
526 if (n == NGX_AGAIN) { 526
527 return NGX_AGAIN; 527 if (n == NGX_AGAIN) {
528 } 528 return NGX_AGAIN;
529 529 }
530 r->headers_in.content_length_n -= n; 530
531 r->headers_in.content_length_n -= n;
532
533 } while (r->connection->read->ready);
531 534
532 return NGX_OK; 535 return NGX_OK;
533 } 536 }