# HG changeset patch # User Maxim Dounin # Date 1521317063 -10800 # Node ID a7ed15573ae9a6e403caa9df29cbd06ad75d2b66 # Parent 22f7bdbd96d33e8fe84468ec069f0131a139e717 Upstream: u->conf->preserve_output flag. The flag can be used to continue sending request body even after we've got a response from the backend. In particular, this is needed for gRPC proxying of bidirectional streaming RPCs, and also to send control frames in other forms of RPCs. diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -2031,7 +2031,9 @@ ngx_http_upstream_send_request(ngx_http_ c->tcp_nopush = NGX_TCP_NOPUSH_UNSET; } - u->write_event_handler = ngx_http_upstream_dummy_handler; + if (!u->conf->preserve_output) { + u->write_event_handler = ngx_http_upstream_dummy_handler; + } if (ngx_handle_write_event(c->write, 0) != NGX_OK) { ngx_http_upstream_finalize_request(r, u, @@ -2193,7 +2195,7 @@ ngx_http_upstream_send_request_handler(n #endif - if (u->header_sent) { + if (u->header_sent && !u->conf->preserve_output) { u->write_event_handler = ngx_http_upstream_dummy_handler; (void) ngx_handle_write_event(c->write, 0); diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h --- a/src/http/ngx_http_upstream.h +++ b/src/http/ngx_http_upstream.h @@ -223,6 +223,7 @@ typedef struct { unsigned intercept_404:1; unsigned change_buffering:1; unsigned pass_trailers:1; + unsigned preserve_output:1; #if (NGX_HTTP_SSL || NGX_COMPAT) ngx_ssl_t *ssl;