restore discard body handler after ngx_http_set_writer() set it to

ngx_http_test_reading(), the bug was introduced in r3050
This commit is contained in:
Igor Sysoev 2009-10-19 16:12:13 +00:00
parent 7060e670f4
commit 801a35df3c
3 changed files with 12 additions and 7 deletions

View File

@ -118,6 +118,7 @@ size_t ngx_http_get_time(char *buf, time_t t);
ngx_int_t ngx_http_discard_request_body(ngx_http_request_t *r);
void ngx_http_discarded_request_body_handler(ngx_http_request_t *r);
void ngx_http_block_reading(ngx_http_request_t *r);
void ngx_http_test_reading(ngx_http_request_t *r);

View File

@ -2105,10 +2105,15 @@ ngx_http_finalize_connection(ngx_http_request_t *r)
if (r->main->count != 1) {
if (r->discard_body && r->lingering_time == 0) {
r->lingering_time = ngx_time()
if (r->discard_body) {
r->read_event_handler = ngx_http_discarded_request_body_handler;
r->write_event_handler = ngx_http_request_empty_handler;
if (r->lingering_time == 0) {
r->lingering_time = ngx_time()
+ (time_t) (clcf->lingering_time / 1000);
ngx_add_timer(r->connection->read, clcf->lingering_timeout);
ngx_add_timer(r->connection->read, clcf->lingering_timeout);
}
}
ngx_http_close_request(r, 0);

View File

@ -13,7 +13,6 @@ static void ngx_http_read_client_request_body_handler(ngx_http_request_t *r);
static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r);
static ngx_int_t ngx_http_write_request_body(ngx_http_request_t *r,
ngx_chain_t *body);
static void ngx_http_read_discarded_request_body_handler(ngx_http_request_t *r);
static ngx_int_t ngx_http_read_discarded_request_body(ngx_http_request_t *r);
static ngx_int_t ngx_http_test_expect(ngx_http_request_t *r);
@ -470,7 +469,7 @@ ngx_http_discard_request_body(ngx_http_request_t *r)
}
}
r->read_event_handler = ngx_http_read_discarded_request_body_handler;
r->read_event_handler = ngx_http_discarded_request_body_handler;
if (ngx_handle_read_event(rev, 0) != NGX_OK) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
@ -488,8 +487,8 @@ ngx_http_discard_request_body(ngx_http_request_t *r)
}
static void
ngx_http_read_discarded_request_body_handler(ngx_http_request_t *r)
void
ngx_http_discarded_request_body_handler(ngx_http_request_t *r)
{
ngx_int_t rc;
ngx_msec_t timer;