]> git.kaiwu.me - nginx.git/commitdiff
HTTP/3: reset streams with incomplete responses or timeouts.
authorRoman Arutyunyan <arut@nginx.com>
Mon, 27 Sep 2021 14:08:48 +0000 (17:08 +0300)
committerRoman Arutyunyan <arut@nginx.com>
Mon, 27 Sep 2021 14:08:48 +0000 (17:08 +0300)
This prevents client from closing the QUIC connection due to response parse
error.

src/http/ngx_http_request.c

index 6496a54003f30928a91a1002c1f8f6c07dd6d4f4..e37ef80248dfcf6dac705b6c770f1cd1cbb1e985 100644 (file)
@@ -3746,6 +3746,12 @@ ngx_http_free_request(ngx_http_request_t *r, ngx_int_t rc)
     if (r->connection->timedout) {
         clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
 
+#if (NGX_HTTP_V3)
+        if (r->connection->quic) {
+            (void) ngx_quic_reset_stream(r->connection,
+                                       NGX_HTTP_V3_ERR_GENERAL_PROTOCOL_ERROR);
+        } else
+#endif
         if (clcf->reset_timedout_connection) {
             linger.l_onoff = 1;
             linger.l_linger = 0;
@@ -3757,6 +3763,14 @@ ngx_http_free_request(ngx_http_request_t *r, ngx_int_t rc)
                               "setsockopt(SO_LINGER) failed");
             }
         }
+
+    } else if (!r->response_sent) {
+#if (NGX_HTTP_V3)
+        if (r->connection->quic) {
+            (void) ngx_quic_reset_stream(r->connection,
+                                         NGX_HTTP_V3_ERR_INTERNAL_ERROR);
+        }
+#endif
     }
 
     /* the various request strings were allocated from r->pool */