aboutsummaryrefslogtreecommitdiff
path: root/src/http/v3/ngx_http_v3_request.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2021-10-18 15:22:33 +0300
committerRoman Arutyunyan <arut@nginx.com>2021-10-18 15:22:33 +0300
commit6118ec73cfef53897d00cc81810ee661321f0057 (patch)
tree876ce7e6d0584327a043ba6a1910a345cc5759eb /src/http/v3/ngx_http_v3_request.c
parent1562200066d73a037ecfa4e15548cbcc239b354f (diff)
downloadnginx-6118ec73cfef53897d00cc81810ee661321f0057.tar.gz
nginx-6118ec73cfef53897d00cc81810ee661321f0057.zip
HTTP/3: adjusted QUIC connection finalization.
When an HTTP/3 function returns an error in context of a QUIC stream, it's this function's responsibility now to finalize the entire QUIC connection with the right code, if required. Previously, QUIC connection finalization could be done both outside and inside such functions. The new rule follows a similar rule for logging, leads to cleaner code, and allows to provide more details about the error. While here, a few error cases are no longer treated as fatal and QUIC connection is no longer finalized in these cases. A few other cases now lead to stream reset instead of connection finalization.
Diffstat (limited to 'src/http/v3/ngx_http_v3_request.c')
-rw-r--r--src/http/v3/ngx_http_v3_request.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/http/v3/ngx_http_v3_request.c b/src/http/v3/ngx_http_v3_request.c
index bb9a72248..5c905bc3a 100644
--- a/src/http/v3/ngx_http_v3_request.c
+++ b/src/http/v3/ngx_http_v3_request.c
@@ -65,8 +65,6 @@ ngx_http_v3_init(ngx_connection_t *c)
ngx_http_core_srv_conf_t *cscf;
if (ngx_http_v3_init_session(c) != NGX_OK) {
- ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_INTERNAL_ERROR,
- "internal error");
ngx_http_close_connection(c);
return;
}
@@ -110,8 +108,6 @@ ngx_http_v3_init(ngx_connection_t *c)
h3c->goaway = 1;
if (ngx_http_v3_send_goaway(c, (n + 1) << 2) != NGX_OK) {
- ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_INTERNAL_ERROR,
- "goaway error");
ngx_http_close_connection(c);
return;
}
@@ -287,15 +283,14 @@ ngx_http_v3_process_request(ngx_event_t *rev)
rc = ngx_http_v3_parse_headers(c, st, b);
if (rc > 0) {
- ngx_http_v3_finalize_connection(c, rc,
- "could not parse request headers");
+ ngx_quic_reset_stream(c, rc);
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+ "client sent invalid header");
ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
break;
}
if (rc == NGX_ERROR) {
- ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_INTERNAL_ERROR,
- "internal error");
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
break;
}
@@ -1167,17 +1162,13 @@ ngx_http_v3_request_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
}
if (rc > 0) {
- ngx_http_v3_finalize_connection(r->connection, rc,
- "client sent invalid body");
+ ngx_quic_reset_stream(r->connection, rc);
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"client sent invalid body");
return NGX_HTTP_BAD_REQUEST;
}
if (rc == NGX_ERROR) {
- ngx_http_v3_finalize_connection(r->connection,
- NGX_HTTP_V3_ERR_INTERNAL_ERROR,
- "internal error");
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}