Mercurial > hg > nginx-vendor-1-0
comparison src/http/ngx_http_request_body.c @ 538:1dcf6adad484 NGINX_0_8_21
nginx 0.8.21
*) Feature: now the "-V" switch shows TLS SNI support.
*) Feature: the "listen" directive of the HTTP module supports unix
domain sockets.
Thanks to Hongli Lai.
*) Feature: the "default_server" parameter of the "listen" directive.
*) Feature: now a "default" parameter is not required to set listen
socket options.
*) Bugfix: nginx did not support dates in 2038 year on 32-bit platforms;
*) Bugfix: socket leak; the bug had appeared in 0.8.11.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 26 Oct 2009 00:00:00 +0300 |
parents | f7ec98e3caeb |
children | 0d6525917227 |
comparison
equal
deleted
inserted
replaced
537:3ca2e495d9de | 538:1dcf6adad484 |
---|---|
11 | 11 |
12 static void ngx_http_read_client_request_body_handler(ngx_http_request_t *r); | 12 static void ngx_http_read_client_request_body_handler(ngx_http_request_t *r); |
13 static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r); | 13 static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r); |
14 static ngx_int_t ngx_http_write_request_body(ngx_http_request_t *r, | 14 static ngx_int_t ngx_http_write_request_body(ngx_http_request_t *r, |
15 ngx_chain_t *body); | 15 ngx_chain_t *body); |
16 static void ngx_http_read_discarded_request_body_handler(ngx_http_request_t *r); | |
17 static ngx_int_t ngx_http_read_discarded_request_body(ngx_http_request_t *r); | 16 static ngx_int_t ngx_http_read_discarded_request_body(ngx_http_request_t *r); |
18 static ngx_int_t ngx_http_test_expect(ngx_http_request_t *r); | 17 static ngx_int_t ngx_http_test_expect(ngx_http_request_t *r); |
19 | 18 |
20 | 19 |
21 /* | 20 /* |
458 | 457 |
459 size = r->header_in->last - r->header_in->pos; | 458 size = r->header_in->last - r->header_in->pos; |
460 | 459 |
461 if (size) { | 460 if (size) { |
462 if (r->headers_in.content_length_n > size) { | 461 if (r->headers_in.content_length_n > size) { |
462 r->header_in->pos += size; | |
463 r->headers_in.content_length_n -= size; | 463 r->headers_in.content_length_n -= size; |
464 | 464 |
465 } else { | 465 } else { |
466 r->header_in->pos += (size_t) r->headers_in.content_length_n; | 466 r->header_in->pos += (size_t) r->headers_in.content_length_n; |
467 r->headers_in.content_length_n = 0; | 467 r->headers_in.content_length_n = 0; |
468 return NGX_OK; | 468 return NGX_OK; |
469 } | 469 } |
470 } | 470 } |
471 | 471 |
472 r->read_event_handler = ngx_http_read_discarded_request_body_handler; | 472 r->read_event_handler = ngx_http_discarded_request_body_handler; |
473 | 473 |
474 if (ngx_handle_read_event(rev, 0) != NGX_OK) { | 474 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
475 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 475 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
476 } | 476 } |
477 | 477 |
485 | 485 |
486 return NGX_OK; | 486 return NGX_OK; |
487 } | 487 } |
488 | 488 |
489 | 489 |
490 static void | 490 void |
491 ngx_http_read_discarded_request_body_handler(ngx_http_request_t *r) | 491 ngx_http_discarded_request_body_handler(ngx_http_request_t *r) |
492 { | 492 { |
493 ngx_int_t rc; | 493 ngx_int_t rc; |
494 ngx_msec_t timer; | 494 ngx_msec_t timer; |
495 ngx_event_t *rev; | 495 ngx_event_t *rev; |
496 ngx_connection_t *c; | 496 ngx_connection_t *c; |
500 rev = c->read; | 500 rev = c->read; |
501 | 501 |
502 if (rev->timedout) { | 502 if (rev->timedout) { |
503 c->timedout = 1; | 503 c->timedout = 1; |
504 c->error = 1; | 504 c->error = 1; |
505 ngx_http_finalize_request(r, 0); | 505 ngx_http_finalize_request(r, NGX_ERROR); |
506 return; | 506 return; |
507 } | 507 } |
508 | 508 |
509 if (r->lingering_time) { | 509 if (r->lingering_time) { |
510 timer = (ngx_msec_t) (r->lingering_time - ngx_time()); | 510 timer = (ngx_msec_t) (r->lingering_time - ngx_time()); |
511 | 511 |
512 if (timer <= 0) { | 512 if (timer <= 0) { |
513 r->discard_body = 0; | 513 r->discard_body = 0; |
514 r->lingering_close = 0; | 514 r->lingering_close = 0; |
515 ngx_http_finalize_request(r, 0); | 515 ngx_http_finalize_request(r, NGX_ERROR); |
516 return; | 516 return; |
517 } | 517 } |
518 | 518 |
519 } else { | 519 } else { |
520 timer = 0; | 520 timer = 0; |
521 } | 521 } |
522 | 522 |
523 rc = ngx_http_read_discarded_request_body(r); | 523 rc = ngx_http_read_discarded_request_body(r); |
524 | 524 |
525 if (rc == NGX_OK) { | 525 if (rc == NGX_OK) { |
526 | |
527 r->discard_body = 0; | 526 r->discard_body = 0; |
528 r->lingering_close = 0; | 527 r->lingering_close = 0; |
529 | 528 ngx_http_finalize_request(r, NGX_DONE); |
530 if (r->done) { | |
531 ngx_http_finalize_request(r, 0); | |
532 } | |
533 | |
534 return; | 529 return; |
535 } | 530 } |
536 | 531 |
537 /* rc == NGX_AGAIN */ | 532 /* rc == NGX_AGAIN */ |
538 | 533 |
539 if (ngx_handle_read_event(rev, 0) != NGX_OK) { | 534 if (ngx_handle_read_event(rev, 0) != NGX_OK) { |
540 c->error = 1; | 535 c->error = 1; |
541 ngx_http_finalize_request(r, rc); | 536 ngx_http_finalize_request(r, NGX_ERROR); |
542 return; | 537 return; |
543 } | 538 } |
544 | 539 |
545 if (timer) { | 540 if (timer) { |
546 | 541 |