]> git.kaiwu.me - nginx.git/commitdiff
HTTP/3: reordered H3_MISSING_SETTINGS and H3_FRAME_UNEXPECTED.
authorRoman Arutyunyan <arut@nginx.com>
Fri, 11 Jun 2021 07:56:51 +0000 (10:56 +0300)
committerRoman Arutyunyan <arut@nginx.com>
Fri, 11 Jun 2021 07:56:51 +0000 (10:56 +0300)
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.

src/http/v3/ngx_http_v3_parse.c

index 21c73a24daa87a6af7de6148e222685c998cd24c..bd528963185950f324ec0d6884499f98ebea2b08 100644 (file)
@@ -1031,6 +1031,12 @@ ngx_http_v3_parse_control(ngx_connection_t *c, ngx_http_v3_parse_control_t *st,
         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_t *c, ngx_http_v3_parse_control_t *st,
             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;