]> git.kaiwu.me - nginx.git/commitdiff
Upstream: u->conf->preserve_output flag.
authorMaxim Dounin <mdounin@mdounin.ru>
Sat, 17 Mar 2018 20:04:23 +0000 (23:04 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Sat, 17 Mar 2018 20:04:23 +0000 (23:04 +0300)
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.

src/http/ngx_http_upstream.c
src/http/ngx_http_upstream.h

index bc98f81bcb2e59b9063c0ffcdec8b2172cff364a..680b664be776cd1663bbd14f38dac52059e82762 100644 (file)
@@ -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);
index 80fa8b3cba9061e080f6c95a927ad4e341a8616a..c2f4dc0ba782884fd8be4821e2c06eb938810c45 100644 (file)
@@ -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;