aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_request.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2021-10-18 15:47:06 +0300
committerRoman Arutyunyan <arut@nginx.com>2021-10-18 15:47:06 +0300
commita6fb8fe85077bd10e11231c70ece803284890520 (patch)
tree6bc3840c63acaf0c38cb7db79073826c57085edc /src/http/ngx_http_request.c
parent6118ec73cfef53897d00cc81810ee661321f0057 (diff)
downloadnginx-a6fb8fe85077bd10e11231c70ece803284890520.tar.gz
nginx-a6fb8fe85077bd10e11231c70ece803284890520.zip
HTTP/3: allowed QUIC stream connection reuse.
A QUIC stream connection is treated as reusable until first bytes of request arrive, which is also when the request object is now allocated. A connection closed as a result of draining, is reset with the error code H3_REQUEST_REJECTED. Such behavior is allowed by quic-http-34: Once a request stream has been opened, the request MAY be cancelled by either endpoint. Clients cancel requests if the response is no longer of interest; servers cancel requests if they are unable to or choose not to respond. When the server cancels a request without performing any application processing, the request is considered "rejected." The server SHOULD abort its response stream with the error code H3_REQUEST_REJECTED. The client can treat requests rejected by the server as though they had never been sent at all, thereby allowing them to be retried later.
Diffstat (limited to 'src/http/ngx_http_request.c')
-rw-r--r--src/http/ngx_http_request.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 88516cb4d..7125e7dd1 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -3731,15 +3731,14 @@ ngx_http_free_request(ngx_http_request_t *r, ngx_int_t rc)
log->action = "closing request";
- if (r->connection->timedout) {
+ if (r->connection->timedout
+#if (NGX_HTTP_QUIC)
+ && r->connection->quic == NULL
+#endif
+ )
+ {
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;
@@ -3751,14 +3750,6 @@ 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 */
@@ -3818,6 +3809,12 @@ ngx_http_close_connection(ngx_connection_t *c)
#endif
+#if (NGX_HTTP_V3)
+ if (ngx_http_v3_connection(c)) {
+ ngx_http_v3_reset_connection(c);
+ }
+#endif
+
#if (NGX_STAT_STUB)
(void) ngx_atomic_fetch_add(ngx_stat_active, -1);
#endif