Mercurial > hg > nginx-vendor-0-8
comparison src/http/ngx_http_request_body.c @ 326:9fc4ab6673f9 NGINX_0_6_7
nginx 0.6.7
*) Change: now the paths specified in the "include",
"auth_basic_user_file", "perl_modules", "ssl_certificate",
"ssl_certificate_key", and "ssl_client_certificate" directives are
relative to directory of nginx configuration file nginx.conf, but
not to nginx prefix directory.
*) Change: the --sysconfdir=PATH option in configure was canceled.
*) Change: the special make target "upgrade1" was defined for online
upgrade of 0.1.x versions.
*) Feature: the "server_name" and "valid_referers" directives support
regular expressions.
*) Feature: the "server" directive in the "upstream" context supports
the "backup" parameter.
*) Feature: the ngx_http_perl_module supports the
$r->discard_request_body.
*) Feature: the "add_header Last-Modified ..." directive changes the
"Last-Modified" response header line.
*) Bugfix: if an response different than 200 was returned to an request
with body and connection went to the keep-alive state after the
request, then nginx returned 400 for the next request.
*) Bugfix: a segmentation fault occurred in worker process if invalid
address was set in the "auth_http" directive.
*) Bugfix: now nginx uses default listen backlog value 511 on all
platforms except FreeBSD.
Thanks to Jiang Hong.
*) Bugfix: a worker process may got caught in an endless loop, if an
"server" inside "upstream" block was marked as "down"; bug appeared
in 0.6.6.
*) Bugfix: now Solaris sendfilev() is not used to transfer the client
request body to FastCGI-server via the unix domain socket.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 15 Aug 2007 00:00:00 +0400 |
parents | fc223117327f |
children | 5e3b425174f6 |
comparison
equal
deleted
inserted
replaced
325:f395c7a4c8a8 | 326:9fc4ab6673f9 |
---|---|
12 | 12 |
13 static void ngx_http_read_client_request_body_handler(ngx_http_request_t *r); | 13 static void ngx_http_read_client_request_body_handler(ngx_http_request_t *r); |
14 static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r); | 14 static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r); |
15 static ngx_int_t ngx_http_write_request_body(ngx_http_request_t *r, | 15 static ngx_int_t ngx_http_write_request_body(ngx_http_request_t *r, |
16 ngx_chain_t *body); | 16 ngx_chain_t *body); |
17 static void ngx_http_read_discarded_body_handler(ngx_http_request_t *r); | 17 static void ngx_http_read_discarded_request_body_handler(ngx_http_request_t *r); |
18 static ngx_int_t ngx_http_read_discarded_body(ngx_http_request_t *r); | 18 static ngx_int_t ngx_http_read_discarded_request_body(ngx_http_request_t *r); |
19 | 19 |
20 | 20 |
21 /* | 21 /* |
22 * on completion ngx_http_read_client_request_body() adds to | 22 * on completion ngx_http_read_client_request_body() adds to |
23 * r->request_body->bufs one or two bufs: | 23 * r->request_body->bufs one or two bufs: |
423 return NGX_OK; | 423 return NGX_OK; |
424 } | 424 } |
425 | 425 |
426 | 426 |
427 ngx_int_t | 427 ngx_int_t |
428 ngx_http_discard_body(ngx_http_request_t *r) | 428 ngx_http_discard_request_body(ngx_http_request_t *r) |
429 { | 429 { |
430 ssize_t size; | 430 ssize_t size; |
431 ngx_event_t *rev; | 431 ngx_event_t *rev; |
432 | 432 |
433 if (r != r->main || r->discard_body) { | 433 if (r != r->main || r->discard_body) { |
440 | 440 |
441 if (rev->timer_set) { | 441 if (rev->timer_set) { |
442 ngx_del_timer(rev); | 442 ngx_del_timer(rev); |
443 } | 443 } |
444 | 444 |
445 r->discard_body = 1; | |
446 | |
447 if (r->headers_in.content_length_n <= 0) { | 445 if (r->headers_in.content_length_n <= 0) { |
448 return NGX_OK; | 446 return NGX_OK; |
449 } | 447 } |
448 | |
449 r->discard_body = 1; | |
450 | 450 |
451 size = r->header_in->last - r->header_in->pos; | 451 size = r->header_in->last - r->header_in->pos; |
452 | 452 |
453 if (size) { | 453 if (size) { |
454 if (r->headers_in.content_length_n > size) { | 454 if (r->headers_in.content_length_n > size) { |
459 r->headers_in.content_length_n = 0; | 459 r->headers_in.content_length_n = 0; |
460 return NGX_OK; | 460 return NGX_OK; |
461 } | 461 } |
462 } | 462 } |
463 | 463 |
464 r->read_event_handler = ngx_http_read_discarded_body_handler; | 464 r->read_event_handler = ngx_http_read_discarded_request_body_handler; |
465 | 465 |
466 if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { | 466 if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { |
467 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 467 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
468 } | 468 } |
469 | 469 |
470 return ngx_http_read_discarded_body(r); | 470 (void) ngx_http_read_discarded_request_body(r); |
471 | |
472 return NGX_OK; | |
471 } | 473 } |
472 | 474 |
473 | 475 |
474 static void | 476 static void |
475 ngx_http_read_discarded_body_handler(ngx_http_request_t *r) | 477 ngx_http_read_discarded_request_body_handler(ngx_http_request_t *r) |
476 { | 478 { |
477 ngx_int_t rc; | 479 ngx_int_t rc; |
478 | 480 ngx_msec_t timer; |
479 rc = ngx_http_read_discarded_body(r); | 481 ngx_event_t *rev; |
480 | 482 ngx_connection_t *c; |
481 if (rc == NGX_AGAIN) { | 483 ngx_http_core_loc_conf_t *clcf; |
482 if (ngx_handle_read_event(r->connection->read, 0) == NGX_ERROR) { | 484 |
483 ngx_http_finalize_request(r, rc); | 485 c = r->connection; |
486 rev = c->read; | |
487 | |
488 if (rev->timedout) { | |
489 c->timedout = 1; | |
490 c->error = 1; | |
491 ngx_http_finalize_request(r, 0); | |
492 return; | |
493 } | |
494 | |
495 if (r->lingering_time) { | |
496 timer = r->lingering_time - ngx_time(); | |
497 | |
498 if (timer <= 0) { | |
499 r->discard_body = 0; | |
500 ngx_http_finalize_request(r, 0); | |
484 return; | 501 return; |
485 } | 502 } |
486 } | 503 |
487 | 504 } else { |
488 if (rc != NGX_OK) { | 505 timer = 0; |
506 } | |
507 | |
508 rc = ngx_http_read_discarded_request_body(r); | |
509 | |
510 if (rc == NGX_OK) { | |
511 | |
512 r->discard_body = 0; | |
513 | |
514 if (r->done) { | |
515 ngx_http_finalize_request(r, 0); | |
516 } | |
517 | |
518 return; | |
519 } | |
520 | |
521 /* rc == NGX_AGAIN */ | |
522 | |
523 if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { | |
489 ngx_http_finalize_request(r, rc); | 524 ngx_http_finalize_request(r, rc); |
525 return; | |
526 } | |
527 | |
528 if (timer) { | |
529 | |
530 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
531 | |
532 timer *= 1000; | |
533 | |
534 if (timer > clcf->lingering_timeout) { | |
535 timer = clcf->lingering_timeout; | |
536 } | |
537 | |
538 ngx_add_timer(rev, timer); | |
490 } | 539 } |
491 } | 540 } |
492 | 541 |
493 | 542 |
494 static ngx_int_t | 543 static ngx_int_t |
495 ngx_http_read_discarded_body(ngx_http_request_t *r) | 544 ngx_http_read_discarded_request_body(ngx_http_request_t *r) |
496 { | 545 { |
497 size_t size; | 546 size_t size; |
498 ssize_t n; | 547 ssize_t n; |
499 u_char buffer[NGX_HTTP_DISCARD_BUFFER_SIZE]; | 548 u_char buffer[NGX_HTTP_DISCARD_BUFFER_SIZE]; |
500 | 549 |
501 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 550 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
502 "http read discarded body"); | 551 "http read discarded body"); |
503 | 552 |
504 if (r->headers_in.content_length_n == 0) { | 553 do { |
505 return NGX_OK; | 554 if (r->headers_in.content_length_n == 0) { |
506 } | 555 r->read_event_handler = ngx_http_block_reading; |
507 | 556 return NGX_OK; |
508 size = (r->headers_in.content_length_n > NGX_HTTP_DISCARD_BUFFER_SIZE) ? | 557 } |
509 NGX_HTTP_DISCARD_BUFFER_SIZE: | 558 |
510 (size_t) r->headers_in.content_length_n; | 559 size = (r->headers_in.content_length_n > NGX_HTTP_DISCARD_BUFFER_SIZE) ? |
511 | 560 NGX_HTTP_DISCARD_BUFFER_SIZE: |
512 n = r->connection->recv(r->connection, buffer, size); | 561 (size_t) r->headers_in.content_length_n; |
513 | 562 |
514 if (n == NGX_ERROR) { | 563 n = r->connection->recv(r->connection, buffer, size); |
515 | 564 |
516 r->connection->error = 1; | 565 if (n == NGX_ERROR) { |
517 | 566 r->connection->error = 1; |
518 /* | 567 return NGX_OK; |
519 * if a client request body is discarded then we already set | 568 } |
520 * some HTTP response code for client and we can ignore the error | 569 |
521 */ | 570 if (n == NGX_AGAIN) { |
522 | 571 return NGX_AGAIN; |
523 return NGX_OK; | 572 } |
524 } | 573 |
525 | 574 r->headers_in.content_length_n -= n; |
526 if (n == NGX_AGAIN) { | 575 |
527 return NGX_AGAIN; | 576 } while (r->connection->read->ready); |
528 } | 577 |
529 | 578 return NGX_AGAIN; |
530 r->headers_in.content_length_n -= n; | 579 } |
531 | |
532 return NGX_OK; | |
533 } |