aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2018-03-17 23:04:23 +0300
committerMaxim Dounin <mdounin@mdounin.ru>2018-03-17 23:04:23 +0300
commitc67124190c9caf42c9d63b889945f73ccafa3ac6 (patch)
tree0addffbcb372f8d6561686b4df238e7f6b2437f2
parent7be60194c12d3565c0ad34cc65206f4c22d4af53 (diff)
downloadnginx-c67124190c9caf42c9d63b889945f73ccafa3ac6.tar.gz
nginx-c67124190c9caf42c9d63b889945f73ccafa3ac6.zip
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.
-rw-r--r--src/http/ngx_http_upstream.c6
-rw-r--r--src/http/ngx_http_upstream.h1
2 files changed, 5 insertions, 2 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index bc98f81bc..680b664be 100644
--- 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_request_t *r, ngx_http_upstream_t *u,
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(ngx_http_request_t *r,
#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
index 80fa8b3cb..c2f4dc0ba 100644
--- 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;