# HG changeset patch # User Roman Arutyunyan # Date 1623398211 -10800 # Node ID ba5977b38b2e6a79d4e652dd9d9a197740c45a21 # Parent 80d396fd8ee8bb67fa3d7c66d7dfdd0522d2b73c HTTP/3: reordered H3_MISSING_SETTINGS and H3_FRAME_UNEXPECTED. The quic-http-34 is ambiguous as to what error should be generated for the first frame in control stream: Each side MUST initiate a single control stream at the beginning of the connection and send its SETTINGS frame as the first frame on this stream. If the first frame of the control stream is any other frame type, this MUST be treated as a connection error of type H3_MISSING_SETTINGS. If a DATA frame is received on a control stream, the recipient MUST respond with a connection error of type H3_FRAME_UNEXPECTED. If a HEADERS frame is received on a control stream, the recipient MUST respond with a connection error of type H3_FRAME_UNEXPECTED. Previously, H3_FRAME_UNEXPECTED had priority, but now H3_MISSING_SETTINGS has. The arguments in the spec sound more compelling for H3_MISSING_SETTINGS. diff --git a/src/http/v3/ngx_http_v3_parse.c b/src/http/v3/ngx_http_v3_parse.c --- a/src/http/v3/ngx_http_v3_parse.c +++ b/src/http/v3/ngx_http_v3_parse.c @@ -1031,6 +1031,12 @@ ngx_http_v3_parse_control(ngx_connection ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 parse frame type:%ui", st->type); + if (st->state == sw_first_type + && st->type != NGX_HTTP_V3_FRAME_SETTINGS) + { + return NGX_HTTP_V3_ERR_MISSING_SETTINGS; + } + if (ngx_http_v3_is_v2_frame(st->type) || st->type == NGX_HTTP_V3_FRAME_DATA || st->type == NGX_HTTP_V3_FRAME_HEADERS) @@ -1038,12 +1044,6 @@ ngx_http_v3_parse_control(ngx_connection return NGX_HTTP_V3_ERR_FRAME_UNEXPECTED; } - if (st->state == sw_first_type - && st->type != NGX_HTTP_V3_FRAME_SETTINGS) - { - return NGX_HTTP_V3_ERR_MISSING_SETTINGS; - } - st->state = sw_length; break;