diff -r 31dd63dcb9ea src/http/ngx_http_upstream.c --- a/src/http/ngx_http_upstream.c Fri May 23 16:37:05 2014 +0400 +++ b/src/http/ngx_http_upstream.c Tue May 27 15:49:34 2014 +0400 @@ -66,6 +66,8 @@ static void static void ngx_http_upstream_process_non_buffered_request(ngx_http_request_t *r, ngx_uint_t do_write); +static ngx_int_t ngx_http_upstream_output_filter(ngx_http_request_t *r, + ngx_chain_t *in); static ngx_int_t ngx_http_upstream_non_buffered_filter_init(void *data); static ngx_int_t ngx_http_upstream_non_buffered_filter(void *data, ssize_t bytes); @@ -2347,23 +2349,9 @@ ngx_http_upstream_send_response(ngx_http c = r->connection; - if (r->header_only) { - - if (u->cacheable || u->store) { - - if (ngx_shutdown_socket(c->fd, NGX_WRITE_SHUTDOWN) == -1) { - ngx_connection_error(c, ngx_socket_errno, - ngx_shutdown_socket_n " failed"); - } - - r->read_event_handler = ngx_http_request_empty_handler; - r->write_event_handler = ngx_http_request_empty_handler; - c->error = 1; - - } else { - ngx_http_upstream_finalize_request(r, u, rc); - return; - } + if (r->header_only && !(u->cacheable || u->store)) { + ngx_http_upstream_finalize_request(r, u, rc); + return; } if (r->request_body && r->request_body->temp_file) { @@ -2515,7 +2503,9 @@ ngx_http_upstream_send_response(ngx_http p = u->pipe; - p->output_filter = (ngx_event_pipe_output_filter_pt) ngx_http_output_filter; + p->output_filter = + (ngx_event_pipe_output_filter_pt) ngx_http_upstream_output_filter; + p->output_ctx = r; p->tag = u->output.tag; p->bufs = u->conf->bufs; @@ -2976,7 +2966,7 @@ ngx_http_upstream_process_non_buffered_r if (do_write) { if (u->out_bufs || u->busy_bufs) { - rc = ngx_http_output_filter(r, u->out_bufs); + rc = ngx_http_upstream_output_filter(r, u->out_bufs); if (rc == NGX_ERROR) { ngx_http_upstream_finalize_request(r, u, NGX_ERROR); @@ -3076,6 +3066,23 @@ ngx_http_upstream_process_non_buffered_r static ngx_int_t +ngx_http_upstream_output_filter(ngx_http_request_t *r, ngx_chain_t *in) +{ + + if (!r->header_only) { + return ngx_http_output_filter(r, in); + } + + while (in) { + in->buf->pos = in->buf->last; + in = in->next; + } + + return NGX_OK; +} + + +static ngx_int_t ngx_http_upstream_non_buffered_filter_init(void *data) { return NGX_OK;