diff options
author | Igor Sysoev <igor@sysoev.ru> | 2003-10-10 15:10:50 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2003-10-10 15:10:50 +0000 |
commit | b3e73d869ecef9248468e0ccc2d7d0abdbee495c (patch) | |
tree | 78f032c1884aca4879ef86ce15f10f923111f66e /src/http | |
parent | 1342d9cc29de7b6509a44a49cd66d1038d1e6d26 (diff) | |
download | nginx-b3e73d869ecef9248468e0ccc2d7d0abdbee495c.tar.gz nginx-b3e73d869ecef9248468e0ccc2d7d0abdbee495c.zip |
nginx-0.0.1-2003-10-10-19:10:50 import
Diffstat (limited to 'src/http')
-rw-r--r-- | src/http/modules/ngx_http_static_handler.c | 42 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.c | 4 | ||||
-rw-r--r-- | src/http/ngx_http.c | 17 | ||||
-rw-r--r-- | src/http/ngx_http.h | 4 | ||||
-rw-r--r-- | src/http/ngx_http_core_module.c | 146 | ||||
-rw-r--r-- | src/http/ngx_http_core_module.h | 18 | ||||
-rw-r--r-- | src/http/ngx_http_header_filter.c | 23 | ||||
-rw-r--r-- | src/http/ngx_http_output_filter.c | 4 | ||||
-rw-r--r-- | src/http/ngx_http_request.c | 81 | ||||
-rw-r--r-- | src/http/ngx_http_request.h | 8 | ||||
-rw-r--r-- | src/http/ngx_http_special_response.c | 34 | ||||
-rw-r--r-- | src/http/ngx_http_write_filter.c | 4 |
12 files changed, 204 insertions, 181 deletions
diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c index 784f3de4d..b8aa8d443 100644 --- a/src/http/modules/ngx_http_static_handler.c +++ b/src/http/modules/ngx_http_static_handler.c @@ -127,33 +127,12 @@ int ngx_http_static_handler(ngx_http_request_t *r) rc = ngx_http_send_header(r); - if (rc == NGX_ERROR || rc > NGX_OK) { - ngx_http_finalize_request(r, rc); - return NGX_OK; - } - - if (r->header_only) { - ngx_http_finalize_request(r, rc); - -#if 0 - if (rc == NGX_AGAIN) { - ngx_http_set_write_handler(r); - } else { - ngx_http_finalize_request(r, 0); - } -#endif - - return NGX_OK; + if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) { + return rc; } - -#if 0 h->type = r->main ? NGX_HUNK_FILE : NGX_HUNK_FILE|NGX_HUNK_LAST; -#else - h->type = NGX_HUNK_FILE; -#endif - h->file_pos = 0; h->file_last = ngx_file_size(r->file.info); @@ -161,20 +140,5 @@ int ngx_http_static_handler(ngx_http_request_t *r) h->file->fd = r->file.fd; h->file->log = r->connection->log; - rc = ngx_http_output_filter(r, h); - - ngx_http_finalize_request(r, rc); - -#if 0 - if (r->main == NULL) { - if (rc == NGX_AGAIN) { - ngx_http_set_write_handler(r); - - } else { - ngx_http_finalize_request(r, 0); - } - } -#endif - - return NGX_OK; + return ngx_http_output_filter(r, h); } diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c index 8be3aa341..adb9be5c4 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -1108,7 +1108,9 @@ static int ngx_http_proxy_init(ngx_cycle_t *cycle) ctx = (ngx_http_conf_ctx_t *) cycle->conf_ctx[ngx_http_module.index]; cmcf = ctx->main_conf[ngx_http_core_module.ctx_index]; - ngx_test_null(h, ngx_push_array(&cmcf->translate_handlers), NGX_ERROR); + ngx_test_null(h, ngx_push_array( + &cmcf->phases[NGX_HTTP_TRANSLATE_PHASE].handlers), + NGX_ERROR); *h = ngx_http_proxy_translate_handler; diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c index 551a1e810..48980bbbb 100644 --- a/src/http/ngx_http.c +++ b/src/http/ngx_http.c @@ -203,8 +203,21 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) /* init list of the handlers */ - ngx_init_array(cmcf->translate_handlers, cf->cycle->pool, - 10, sizeof(ngx_http_handler_pt), NGX_CONF_ERROR); + ngx_init_array(cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers, + cf->cycle->pool, 10, sizeof(ngx_http_handler_pt), + NGX_CONF_ERROR); + + cmcf->phases[NGX_HTTP_REWRITE_PHASE].type = NGX_OK; + cmcf->phases[NGX_HTTP_REWRITE_PHASE].post_handler = + ngx_http_find_location_config; + + + ngx_init_array(cmcf->phases[NGX_HTTP_TRANSLATE_PHASE].handlers, + cf->cycle->pool, 10, sizeof(ngx_http_handler_pt), + NGX_CONF_ERROR); + + cmcf->phases[NGX_HTTP_TRANSLATE_PHASE].type = NGX_OK; + ngx_init_array(cmcf->index_handlers, cf->cycle->pool, 3, sizeof(ngx_http_handler_pt), NGX_CONF_ERROR); diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h index 3cdd120c5..63a6adba6 100644 --- a/src/http/ngx_http.h +++ b/src/http/ngx_http.h @@ -17,8 +17,6 @@ typedef struct { } ngx_http_log_ctx_t; -typedef int (*ngx_http_handler_pt)(ngx_http_request_t *r); - typedef int (*ngx_http_output_header_filter_p)(ngx_http_request_t *r); typedef int (*ngx_http_output_body_filter_p) @@ -51,7 +49,7 @@ int ngx_http_parse_header_line(ngx_http_request_t *r, ngx_hunk_t *h); int ngx_http_find_server_conf(ngx_http_request_t *r); void ngx_http_handler(ngx_http_request_t *r); void ngx_http_finalize_request(ngx_http_request_t *r, int error); -void ngx_http_set_write_handler(ngx_http_request_t *r); +void ngx_http_writer(ngx_event_t *wev); int ngx_http_send_last(ngx_http_request_t *r); diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index a895fbd6c..69c741c87 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -1,6 +1,7 @@ #include <ngx_config.h> #include <ngx_core.h> +#include <ngx_event.h> #include <ngx_http.h> #include <nginx.h> @@ -8,6 +9,8 @@ /* STUB */ int ngx_http_static_handler(ngx_http_request_t *r); +static void ngx_http_phase_event_handler(ngx_event_t *rev); +static void ngx_http_run_phases(ngx_http_request_t *r); static int ngx_http_core_index_handler(ngx_http_request_t *r); @@ -201,12 +204,7 @@ ngx_module_t ngx_http_core_module = { void ngx_http_handler(ngx_http_request_t *r) { - int rc, i; - ngx_http_log_ctx_t *lcx; - ngx_http_handler_pt *h; - ngx_http_core_loc_conf_t *clcf, **clcfp; - ngx_http_core_srv_conf_t *cscf; - ngx_http_core_main_conf_t *cmcf; + ngx_http_log_ctx_t *lcx; r->connection->unexpected_eof = 0; @@ -221,11 +219,100 @@ void ngx_http_handler(ngx_http_request_t *r) /* TEST STUB */ r->lingering_close = 1; + r->connection->write->event_handler = ngx_http_phase_event_handler; + + r->phase = 0; + r->phase_handler = 0; + + ngx_http_run_phases(r); + + return; +} + + +static void ngx_http_phase_event_handler(ngx_event_t *ev) +{ + ngx_connection_t *c; + ngx_http_request_t *r; + + c = ev->data; + r = c->data; + + ngx_http_run_phases(r); + + return; +} + + +static void ngx_http_run_phases(ngx_http_request_t *r) +{ + int rc; + ngx_http_handler_pt *h; + ngx_http_core_main_conf_t *cmcf; + + cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); + + rc = NGX_DECLINED; + + for (/* void */; r->phase < NGX_HTTP_LAST_PHASE; r->phase++) { + + h = cmcf->phases[r->phase].handlers.elts; + for (r->phase_handler = cmcf->phases[r->phase].handlers.nelts - 1; + r->phase_handler >= 0; + r->phase_handler--) + { + rc = h[r->phase_handler](r); + + if (rc == NGX_DECLINED) { + continue; + } + + if (rc == NGX_AGAIN) { + return; + } + + if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { + ngx_http_finalize_request(r, rc); + return; + } + + if (rc == NGX_OK && cmcf->phases[r->phase].type == NGX_OK) { + break; + } + } + + if (cmcf->phases[r->phase].post_handler) { + rc = cmcf->phases[r->phase].post_handler(r); - /* TODO: run rewrite url phase */ + if (rc == NGX_AGAIN) { + return; + } + if (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE) { + ngx_http_finalize_request(r, rc); + return; + } + } + } - /* find location config */ + if (r->content_handler) { + r->connection->write->event_handler = ngx_http_writer; + rc = r->content_handler(r); + ngx_http_finalize_request(r, rc); + return; + } + + /* TODO: no handlers found ? */ + ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); + return; +} + + +int ngx_http_find_location_config(ngx_http_request_t *r) +{ + int i, rc; + ngx_http_core_loc_conf_t *clcf, **clcfp; + ngx_http_core_srv_conf_t *cscf; cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); @@ -261,36 +348,7 @@ ngx_log_debug(r->connection->log, "rc: %d" _ rc); r->filter = NGX_HTTP_FILTER_NEED_IN_MEMORY; } - cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); - - /* run translation phase */ - - h = cmcf->translate_handlers.elts; - for (i = cmcf->translate_handlers.nelts - 1; i >= 0; i--) { - - rc = h[i](r); - - if (rc == NGX_DECLINED) { - continue; - } - - if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { - ngx_http_finalize_request(r, rc); - return; - } - - if (rc == NGX_OK) { - rc = r->handler(r); - if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { - ngx_http_finalize_request(r, rc); - } - return; - } - } - - /* TODO: no handlers found ? */ - ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); - return; + return NGX_OK; } @@ -305,14 +363,14 @@ int ngx_http_core_translate_handler(ngx_http_request_t *r) clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); if (clcf->handler) { - r->handler = clcf->handler; + r->content_handler = clcf->handler; return NGX_OK; } cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); if (r->uri.data[r->uri.len - 1] == '/') { - r->handler = ngx_http_core_index_handler; + r->content_handler = ngx_http_core_index_handler; return NGX_OK; } @@ -424,7 +482,7 @@ ngx_log_debug(r->connection->log, "HTTP DIR: '%s'" _ r->file.name.data); return NGX_HTTP_MOVED_PERMANENTLY; } - r->handler = ngx_http_static_handler; + r->content_handler = ngx_http_static_handler; return NGX_OK; } @@ -548,7 +606,9 @@ static int ngx_http_core_init(ngx_cycle_t *cycle) ctx = (ngx_http_conf_ctx_t *) cycle->conf_ctx[ngx_http_module.index]; cmcf = ctx->main_conf[ngx_http_core_module.ctx_index]; - ngx_test_null(h, ngx_push_array(&cmcf->translate_handlers), NGX_ERROR); + ngx_test_null(h, ngx_push_array( + &cmcf->phases[NGX_HTTP_TRANSLATE_PHASE].handlers), + NGX_ERROR); *h = ngx_http_core_translate_handler; @@ -756,7 +816,7 @@ static void *ngx_http_core_create_main_conf(ngx_conf_t *cf) ngx_http_core_main_conf_t *cmcf; ngx_test_null(cmcf, - ngx_palloc(cf->pool, sizeof(ngx_http_core_main_conf_t)), + ngx_pcalloc(cf->pool, sizeof(ngx_http_core_main_conf_t)), NGX_CONF_ERROR); ngx_init_array(cmcf->servers, cf->pool, diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h index 08c1f024e..9cc979145 100644 --- a/src/http/ngx_http_core_module.h +++ b/src/http/ngx_http_core_module.h @@ -18,9 +18,20 @@ typedef struct { typedef struct { - ngx_array_t servers; /* array of ngx_http_core_srv_conf_t */ - ngx_array_t translate_handlers; - ngx_array_t index_handlers; + ngx_array_t handlers; + int type; /* NGX_OK, NGX_DECLINED */ + ngx_http_handler_pt post_handler; +} ngx_http_phase_t; + +#define NGX_HTTP_REWRITE_PHASE 0 +#define NGX_HTTP_TRANSLATE_PHASE 1 +#define NGX_HTTP_LAST_PHASE 2 + +typedef struct { + ngx_array_t servers; /* array of ngx_http_core_srv_conf_t */ + + ngx_http_phase_t phases[NGX_HTTP_LAST_PHASE]; + ngx_array_t index_handlers; } ngx_http_core_main_conf_t; @@ -138,6 +149,7 @@ extern int ngx_http_max_module; +int ngx_http_find_location_config(ngx_http_request_t *r); int ngx_http_core_translate_handler(ngx_http_request_t *r); int ngx_http_internal_redirect(ngx_http_request_t *r, diff --git a/src/http/ngx_http_header_filter.c b/src/http/ngx_http_header_filter.c index ff02c5008..346c33226 100644 --- a/src/http/ngx_http_header_filter.c +++ b/src/http/ngx_http_header_filter.c @@ -4,12 +4,6 @@ #include <ngx_http.h> #include <nginx.h> -/* STUB probably, needed for ngx_freebsd_tcp_nopush_flush */ -#ifdef __FreeBSD__ -#include <ngx_freebsd_init.h> -#endif - - static int ngx_http_header_filter_init(ngx_cycle_t *cycle); static int ngx_http_header_filter(ngx_http_request_t *r); @@ -100,23 +94,6 @@ static int ngx_http_header_filter(ngx_http_request_t *r) ngx_chain_t *ch; ngx_table_elt_t *header; -#ifdef __FreeBSD__ - - if (r->keepalive) { - if (ngx_freebsd_tcp_nopush_flush) { - r->connection->tcp_nopush_enabled = 1; - } - - } else { - r->connection->tcp_nopush_enabled = 1; - } - -#else - - r->connection->tcp_nopush_enabled = 1; - -#endif - if (r->http_version < NGX_HTTP_VERSION_10) { return NGX_OK; } diff --git a/src/http/ngx_http_output_filter.c b/src/http/ngx_http_output_filter.c index 6de920215..0f5b04c0d 100644 --- a/src/http/ngx_http_output_filter.c +++ b/src/http/ngx_http_output_filter.c @@ -203,7 +203,9 @@ int ngx_http_output_filter(ngx_http_request_t *r, ngx_hunk_t *hunk) ctx->last_out = &ce->next; ctx->hunk = NULL; - break; + if (ctx->free == NULL) { + break; + } } if (ctx->out == NULL && last != NGX_NONE) { diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index 0f66b0d40..cde7f1d64 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -10,7 +10,7 @@ static void ngx_http_process_request_line(ngx_event_t *rev); static void ngx_http_process_request_headers(ngx_event_t *rev); static ssize_t ngx_http_read_request_header(ngx_http_request_t *r); -static void ngx_http_writer(ngx_event_t *ev); +static void ngx_http_set_write_handler(ngx_http_request_t *r); static void ngx_http_block_read(ngx_event_t *ev); static void ngx_http_read_discarded_body_event(ngx_event_t *rev); @@ -112,6 +112,13 @@ void ngx_http_init_connection(ngx_connection_t *c) return; } + if (ngx_handle_read_event(rev) == NGX_ERROR) { + ngx_http_close_connection(c); + return; + } + +#if 0 + if (ngx_event_flags & NGX_HAVE_CLEAR_EVENT) { /* kqueue */ event = NGX_CLEAR_EVENT; @@ -124,6 +131,10 @@ void ngx_http_init_connection(ngx_connection_t *c) if (ngx_add_event(rev, NGX_READ_EVENT, event) == NGX_ERROR) { ngx_http_close_connection(c); } + +#endif + + return; } @@ -660,6 +671,7 @@ static void ngx_http_process_request_headers(ngx_event_t *rev) } rev->event_handler = ngx_http_block_read; + c->write->event_handler = ngx_http_writer; ngx_http_handler(r); return; @@ -743,6 +755,13 @@ static ssize_t ngx_http_read_request_header(ngx_http_request_t *r) r->header_timeout_set = 1; } + if (ngx_handle_read_event(rev) == NGX_ERROR) { + ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); + ngx_http_close_connection(r->connection); + return NGX_ERROR; + } + +#if 0 if (!rev->active) { if (ngx_event_flags & NGX_HAVE_CLEAR_EVENT) { /* kqueue */ @@ -759,6 +778,7 @@ static ssize_t ngx_http_read_request_header(ngx_http_request_t *r) return NGX_ERROR; } } +#endif return NGX_AGAIN; } @@ -780,17 +800,14 @@ static ssize_t ngx_http_read_request_header(ngx_http_request_t *r) } -void ngx_http_finalize_request(ngx_http_request_t *r, int error) +void ngx_http_finalize_request(ngx_http_request_t *r, int rc) { - int rc; ngx_event_t *rev, *wev; - if (r->main) { + if (r->main || r->closed) { return; } - rc = error; - if (rc >= NGX_HTTP_SPECIAL_RESPONSE) { rev = r->connection->read; @@ -805,37 +822,18 @@ void ngx_http_finalize_request(ngx_http_request_t *r, int error) wev->timer_set = 0; } - rc = ngx_http_special_response_handler(r, rc); - - if (rc == NGX_AGAIN) { - return; - } + ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc)); - if (rc == NGX_ERROR) { - ngx_http_close_request(r, 0); - ngx_http_close_connection(r->connection); - return; - } - -#if 1 return; -#endif } else if (rc == NGX_ERROR) { - r->keepalive = 0; - r->lingering_close = 0; - - } else { - if (ngx_http_send_last(r) == NGX_ERROR) { - ngx_http_close_request(r, 0); - ngx_http_close_connection(r->connection); - return; - } + ngx_http_close_request(r, 0); + ngx_http_close_connection(r->connection); + return; - if (rc == NGX_AGAIN) { - ngx_http_set_write_handler(r); - return; - } + } else if (rc == NGX_AGAIN) { + ngx_http_set_write_handler(r); + return; } rev = r->connection->read; @@ -865,7 +863,7 @@ void ngx_http_finalize_request(ngx_http_request_t *r, int error) } -void ngx_http_set_write_handler(ngx_http_request_t *r) +static void ngx_http_set_write_handler(ngx_http_request_t *r) { int event; ngx_event_t *wev; @@ -883,6 +881,13 @@ void ngx_http_set_write_handler(ngx_http_request_t *r) ngx_add_timer(wev, clcf->send_timeout); wev->timer_set = 1; + if (ngx_handle_write_event(wev, clcf->send_lowat) == NGX_ERROR) { + ngx_http_close_request(r, 0); + ngx_http_close_connection(r->connection); + } + +#if 0 + if (ngx_event_flags & (NGX_HAVE_AIO_EVENT|NGX_HAVE_EDGE_EVENT)) { /* aio, iocp, epoll */ return; @@ -910,11 +915,13 @@ void ngx_http_set_write_handler(ngx_http_request_t *r) ngx_http_close_connection(r->connection); } +#endif + return; } -static void ngx_http_writer(ngx_event_t *wev) +void ngx_http_writer(ngx_event_t *wev) { int rc; ngx_event_t *rev; @@ -1454,6 +1461,10 @@ void ngx_http_close_request(ngx_http_request_t *r, int error) ctx->url = NULL; ngx_destroy_pool(r->pool); + + r->closed = 1; + + return; } @@ -1497,6 +1508,8 @@ void ngx_http_close_connection(ngx_connection_t *c) c->fd = -1; ngx_destroy_pool(c->pool); + + return; } diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h index 806542ac8..1f8b254b9 100644 --- a/src/http/ngx_http_request.h +++ b/src/http/ngx_http_request.h @@ -126,6 +126,8 @@ typedef struct { typedef struct ngx_http_request_s ngx_http_request_t; +typedef int (*ngx_http_handler_pt)(ngx_http_request_t *r); + struct ngx_http_request_s { ngx_connection_t *connection; @@ -143,8 +145,6 @@ struct ngx_http_request_s { ngx_http_headers_in_t headers_in; ngx_http_headers_out_t headers_out; - int (*handler)(ngx_http_request_t *r); - time_t lingering_time; int method; @@ -166,6 +166,9 @@ struct ngx_http_request_s { ngx_str_t *server_name; ngx_array_t *virtual_names; + int phase; + int phase_handler; + ngx_http_handler_pt content_handler; char *discarded_buffer; @@ -188,6 +191,7 @@ struct ngx_http_request_s { unsigned header_only:1; unsigned keepalive:1; unsigned lingering_close:1; + unsigned closed:1; /* TODO: use filter or bits ???? */ int filter; diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c index 736211654..825d8bc97 100644 --- a/src/http/ngx_http_special_response.c +++ b/src/http/ngx_http_special_response.c @@ -200,20 +200,8 @@ int ngx_http_special_response_handler(ngx_http_request_t *r, int error) rc = ngx_http_send_header(r); - if (rc == NGX_ERROR) { - return NGX_ERROR; - } - - if (r->header_only) { - ngx_http_finalize_request(r, rc); -#if 0 - if (rc == NGX_AGAIN) { - ngx_http_set_write_handler(r); - return NGX_AGAIN; - } -#endif - - return NGX_OK; + if (rc == NGX_ERROR || r->header_only) { + return rc; } if (error_pages[err].len == 0) { @@ -236,7 +224,7 @@ int ngx_http_special_response_handler(ngx_http_request_t *r, int error) h->pos = error_tail; h->last = error_tail + sizeof(error_tail) - 1; - if (1) { + if (/* STUB: "msie_padding on/off" */ 1) { if (ngx_http_output_filter(r, h) == NGX_ERROR) { return NGX_ERROR; } @@ -250,19 +238,5 @@ int ngx_http_special_response_handler(ngx_http_request_t *r, int error) h->type |= NGX_HUNK_LAST; - rc = ngx_http_output_filter(r, h); - - ngx_http_finalize_request(r, rc); - -#if 0 - if (r->main == NULL) { - if (rc == NGX_AGAIN) { - ngx_http_set_write_handler(r); - return NGX_AGAIN; - } - } -#endif - - return NGX_OK; - + return ngx_http_output_filter(r, h); } diff --git a/src/http/ngx_http_write_filter.c b/src/http/ngx_http_write_filter.c index 3f43875bc..cf587508d 100644 --- a/src/http/ngx_http_write_filter.c +++ b/src/http/ngx_http_write_filter.c @@ -143,6 +143,10 @@ int ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) return NGX_AGAIN; } + if (size == 0) { + return NGX_OK; + } + chain = ngx_write_chain(r->connection, ctx->out); #if (NGX_DEBUG_WRITE_FILTER) |