HTTP/3: Header encoding and decoding fixes (#46565)
authorJames Newton-King <james@newtonking.com>
Tue, 5 Jan 2021 19:12:22 +0000 (08:12 +1300)
committerGitHub <noreply@github.com>
Tue, 5 Jan 2021 19:12:22 +0000 (08:12 +1300)
src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackDecoder.cs
src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackEncoder.cs

index 2d50916..a500c9b 100644 (file)
@@ -173,6 +173,8 @@ namespace System.Net.Http.QPack
             {
                 Decode(segment.Span, handler);
             }
+
+            _state = State.RequiredInsertCount;
         }
 
         public void Decode(ReadOnlySpan<byte> headerBlock, IHttpHeadersHandler handler)
index 68e04ed..97b85b4 100644 (file)
@@ -477,9 +477,8 @@ namespace System.Net.Http.QPack
                 case 400:
                 case 404:
                 case 500:
-                    // TODO this isn't safe, some index can be larger than 64. Encoded here!
-                    buffer[0] = (byte)(0xC0 | H3StaticTable.StatusIndex[statusCode]);
-                    return 1;
+                    EncodeStaticIndexedHeaderField(H3StaticTable.StatusIndex[statusCode], buffer, out var bytesWritten);
+                    return bytesWritten;
                 default:
                     // Send as Literal Header Field Without Indexing - Indexed Name
                     buffer[0] = 0x08;