Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The runtime<->aspnetcore shared src is out of sync #18943

Closed
Tratcher opened this issue Feb 10, 2020 · 178 comments · Fixed by #19062, #19206, #19314, #19553 or #19636
Closed

The runtime<->aspnetcore shared src is out of sync #18943

Tratcher opened this issue Feb 10, 2020 · 178 comments · Fixed by #19062, #19206, #19314, #19553 or #19636
Assignees
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions Bot: Do Not Lock Indicates that the bot should not lock this issue due to inactivity. feature-kestrel task

Comments

@Tratcher
Copy link
Member

Tratcher commented Feb 10, 2020

This is a tracking issue for when the shared src gets out of sync with it's runtime counterpart. See the ReadMe for details.

There is a github action that runs daily at https://github.com/dotnet/aspnetcore/actions and will re-open and comment on this bug if it detects any differences in the files shared between the repos. AspNetCore will triage and assign this issue to get the differences resolved.

@analogrelay
Copy link
Contributor

We are currently in-sync.

@github-actions
Copy link
Contributor

The shared code is out of sync.

The Diff
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/runtime/CopyToAspNetCore.cmd
	modified:   src/Shared/runtime/CopyToRuntime.cmd

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/runtime/CopyToAspNetCore.cmd b/src/Shared/runtime/CopyToAspNetCore.cmd
index 43eb681..65a341b 100644
--- a/src/Shared/runtime/CopyToAspNetCore.cmd
+++ b/src/Shared/runtime/CopyToAspNetCore.cmd
@@ -10,5 +10,6 @@ IF [%remote_repo%] == [] (
 
 echo ASPNETCORE_REPO: %remote_repo%
 
-robocopy . %remote_repo%\src\Shared\runtime /MIR
-robocopy .\..\..\..\..\..\tests\Tests\System\Net\aspnetcore\ %remote_repo%\src\Shared\test\Shared.Tests\runtime /MIR
+REM https://superuser.com/questions/280425/getting-robocopy-to-return-a-proper-exit-code
+(robocopy . %remote_repo%\src\Shared\runtime /MIR) ^& IF %ERRORLEVEL% LSS 8 SET ERRORLEVEL = 0
+(robocopy .\..\..\..\..\..\tests\Tests\System\Net\aspnetcore\ %remote_repo%\src\Shared\test\Shared.Tests\runtime /MIR) ^& IF %ERRORLEVEL% LSS 8 SET ERRORLEVEL = 0
diff --git a/src/Shared/runtime/CopyToRuntime.cmd b/src/Shared/runtime/CopyToRuntime.cmd
index 7f9e5b1..f1cb32d 100644
--- a/src/Shared/runtime/CopyToRuntime.cmd
+++ b/src/Shared/runtime/CopyToRuntime.cmd
@@ -10,5 +10,6 @@ IF [%remote_repo%] == [] (
 
 echo RUNTIME_REPO: %remote_repo%
 
-robocopy . %remote_repo%\src\libraries\Common\src\System\Net\Http\aspnetcore /MIR
-robocopy .\..\test\Shared.Tests\runtime %remote_repo%\src\libraries\Common\tests\Tests\System\Net\aspnetcore /MIR
+REM https://superuser.com/questions/280425/getting-robocopy-to-return-a-proper-exit-code
+(robocopy . %remote_repo%\src\libraries\Common\src\System\Net\Http\aspnetcore /MIR) ^& IF %ERRORLEVEL% LSS 8 SET ERRORLEVEL = 0
+(robocopy .\..\test\Shared.Tests\runtime %remote_repo%\src\libraries\Common\tests\Tests\System\Net\aspnetcore /MIR) ^& IF %ERRORLEVEL% LSS 8 SET ERRORLEVEL = 0

@ghost ghost closed this as completed in #19062 Feb 14, 2020
ghost pushed a commit that referenced this issue Feb 14, 2020
* Sync script changes from the runtime repo #18943

* Additional change
@github-actions github-actions bot reopened this Feb 19, 2020
@github-actions
Copy link
Contributor

The shared code is out of sync.

The Diff
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/runtime/Http3/QPack/QPackDecoder.cs

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/runtime/Http3/QPack/QPackDecoder.cs b/src/Shared/runtime/Http3/QPack/QPackDecoder.cs
index 6f63d66..958dfac 100644
--- a/src/Shared/runtime/Http3/QPack/QPackDecoder.cs
+++ b/src/Shared/runtime/Http3/QPack/QPackDecoder.cs
@@ -269,6 +269,10 @@ namespace System.Net.Http.QPack
 
                             if (_integerDecoder.BeginTryDecode((byte)prefixInt, LiteralHeaderFieldWithoutNameReferencePrefix, out intResult))
                             {
+                                if (intResult == 0)
+                                {
+                                    throw new QPackDecodingException(SR.Format(SR.net_http_invalid_header_name, ""));
+                                }
                                 OnStringLength(intResult, State.HeaderName);
                             }
                             else
@@ -303,6 +307,10 @@ namespace System.Net.Http.QPack
                 case State.HeaderNameLength:
                     if (_integerDecoder.TryDecode(b, out intResult))
                     {
+                        if (intResult == 0)
+                        {
+                            throw new QPackDecodingException(SR.Format(SR.net_http_invalid_header_name, ""));
+                        }
                         OnStringLength(intResult, nextState: State.HeaderName);
                     }
                     break;

@github-actions
Copy link
Contributor

The shared code is out of sync.

The Diff
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/runtime/Http3/QPack/QPackDecoder.cs

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/runtime/Http3/QPack/QPackDecoder.cs b/src/Shared/runtime/Http3/QPack/QPackDecoder.cs
index 6f63d66..958dfac 100644
--- a/src/Shared/runtime/Http3/QPack/QPackDecoder.cs
+++ b/src/Shared/runtime/Http3/QPack/QPackDecoder.cs
@@ -269,6 +269,10 @@ namespace System.Net.Http.QPack
 
                             if (_integerDecoder.BeginTryDecode((byte)prefixInt, LiteralHeaderFieldWithoutNameReferencePrefix, out intResult))
                             {
+                                if (intResult == 0)
+                                {
+                                    throw new QPackDecodingException(SR.Format(SR.net_http_invalid_header_name, ""));
+                                }
                                 OnStringLength(intResult, State.HeaderName);
                             }
                             else
@@ -303,6 +307,10 @@ namespace System.Net.Http.QPack
                 case State.HeaderNameLength:
                     if (_integerDecoder.TryDecode(b, out intResult))
                     {
+                        if (intResult == 0)
+                        {
+                            throw new QPackDecodingException(SR.Format(SR.net_http_invalid_header_name, ""));
+                        }
                         OnStringLength(intResult, nextState: State.HeaderName);
                     }
                     break;

@ghost ghost closed this as completed in #19206 Feb 21, 2020
@github-actions github-actions bot reopened this Feb 22, 2020
@github-actions
Copy link
Contributor

The shared code is out of sync.

The Diff
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs
index 536968b..00ca779 100644
--- a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs
+++ b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs
@@ -402,7 +402,7 @@ namespace System.Net.Quic.Implementations.MsQuic
         {
             ThrowIfDisposed();
 
-            return ReadAsync(buffer.ToArray()).GetAwaiter().GetResult();
+            return ReadAsync(buffer.ToArray()).AsTask().GetAwaiter().GetResult();
         }
 
         internal override void Write(ReadOnlySpan<byte> buffer)
@@ -410,7 +410,7 @@ namespace System.Net.Quic.Implementations.MsQuic
             ThrowIfDisposed();
 
             // TODO: optimize this.
-            WriteAsync(buffer.ToArray()).GetAwaiter().GetResult();
+            WriteAsync(buffer.ToArray()).AsTask().GetAwaiter().GetResult();
         }
 
         // MsQuic doesn't support explicit flushing

2 similar comments
@github-actions
Copy link
Contributor

The shared code is out of sync.

The Diff
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs
index 536968b..00ca779 100644
--- a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs
+++ b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs
@@ -402,7 +402,7 @@ namespace System.Net.Quic.Implementations.MsQuic
         {
             ThrowIfDisposed();
 
-            return ReadAsync(buffer.ToArray()).GetAwaiter().GetResult();
+            return ReadAsync(buffer.ToArray()).AsTask().GetAwaiter().GetResult();
         }
 
         internal override void Write(ReadOnlySpan<byte> buffer)
@@ -410,7 +410,7 @@ namespace System.Net.Quic.Implementations.MsQuic
             ThrowIfDisposed();
 
             // TODO: optimize this.
-            WriteAsync(buffer.ToArray()).GetAwaiter().GetResult();
+            WriteAsync(buffer.ToArray()).AsTask().GetAwaiter().GetResult();
         }
 
         // MsQuic doesn't support explicit flushing

@github-actions
Copy link
Contributor

The shared code is out of sync.

The Diff
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs
index 536968b..00ca779 100644
--- a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs
+++ b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs
@@ -402,7 +402,7 @@ namespace System.Net.Quic.Implementations.MsQuic
         {
             ThrowIfDisposed();
 
-            return ReadAsync(buffer.ToArray()).GetAwaiter().GetResult();
+            return ReadAsync(buffer.ToArray()).AsTask().GetAwaiter().GetResult();
         }
 
         internal override void Write(ReadOnlySpan<byte> buffer)
@@ -410,7 +410,7 @@ namespace System.Net.Quic.Implementations.MsQuic
             ThrowIfDisposed();
 
             // TODO: optimize this.
-            WriteAsync(buffer.ToArray()).GetAwaiter().GetResult();
+            WriteAsync(buffer.ToArray()).AsTask().GetAwaiter().GetResult();
         }
 
         // MsQuic doesn't support explicit flushing

@github-actions
Copy link
Contributor

The shared code is out of sync.

The Diff
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/runtime/Http3/QPack/QPackEncoder.cs
	modified:   src/Shared/runtime/Quic/Implementations/MsQuic/Internal/MsQuicApi.cs
	modified:   src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/runtime/Http3/QPack/QPackEncoder.cs b/src/Shared/runtime/Http3/QPack/QPackEncoder.cs
index ecf0f1e..348106a 100644
--- a/src/Shared/runtime/Http3/QPack/QPackEncoder.cs
+++ b/src/Shared/runtime/Http3/QPack/QPackEncoder.cs
@@ -340,6 +340,7 @@ namespace System.Net.Http.QPack
             return true;
         }
 
+        // TODO these are fairly hard coded for the first two bytes to be zero.
         public bool BeginEncode(IEnumerable<KeyValuePair<string, string>> headers, Span<byte> buffer, out int length)
         {
             _enumerator = headers.GetEnumerator();
@@ -350,11 +351,7 @@ namespace System.Net.Http.QPack
             buffer[0] = 0;
             buffer[1] = 0;
 
-            bool doneEncode = Encode(buffer.Slice(2), out length);
-
-            // Add two for the first two bytes.
-            length += 2;
-            return doneEncode;
+            return Encode(buffer.Slice(2), out length);
         }
 
         public bool BeginEncode(int statusCode, IEnumerable<KeyValuePair<string, string>> headers, Span<byte> buffer, out int length)
diff --git a/src/Shared/runtime/Quic/Implementations/MsQuic/Internal/MsQuicApi.cs b/src/Shared/runtime/Quic/Implementations/MsQuic/Internal/MsQuicApi.cs
index fb6330c..30e5cba 100644
--- a/src/Shared/runtime/Quic/Implementations/MsQuic/Internal/MsQuicApi.cs
+++ b/src/Shared/runtime/Quic/Implementations/MsQuic/Internal/MsQuicApi.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+?// Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
@@ -143,6 +143,12 @@ namespace System.Net.Quic.Implementations.MsQuic.Internal
 
             OperatingSystem ver = Environment.OSVersion;
 
+            if (ver.Platform == PlatformID.Win32NT && ver.Version < new Version(10, 0, 19041, 0))
+            {
+                IsQuicSupported = false;
+                return;
+            }
+
             // TODO: try to initialize TLS 1.3 in SslStream.
 
             try
diff --git a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs
index 536968b..00ca779 100644
--- a/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs
+++ b/src/Shared/runtime/Quic/Implementations/MsQuic/MsQuicStream.cs
@@ -402,7 +402,7 @@ namespace System.Net.Quic.Implementations.MsQuic
         {
             ThrowIfDisposed();
 
-            return ReadAsync(buffer.ToArray()).GetAwaiter().GetResult();
+            return ReadAsync(buffer.ToArray()).AsTask().GetAwaiter().GetResult();
         }
 
         internal override void Write(ReadOnlySpan<byte> buffer)
@@ -410,7 +410,7 @@ namespace System.Net.Quic.Implementations.MsQuic
             ThrowIfDisposed();
 
             // TODO: optimize this.
-            WriteAsync(buffer.ToArray()).GetAwaiter().GetResult();
+            WriteAsync(buffer.ToArray()).AsTask().GetAwaiter().GetResult();
         }
 
         // MsQuic doesn't support explicit flushing

@github-actions
Copy link
Contributor

The shared code is out of sync.

The Diff
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/runtime/Http3/QPack/QPackEncoder.cs
	modified:   src/Shared/runtime/Quic/Implementations/MsQuic/Internal/MsQuicApi.cs

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/runtime/Http3/QPack/QPackEncoder.cs b/src/Shared/runtime/Http3/QPack/QPackEncoder.cs
index ecf0f1e..348106a 100644
--- a/src/Shared/runtime/Http3/QPack/QPackEncoder.cs
+++ b/src/Shared/runtime/Http3/QPack/QPackEncoder.cs
@@ -340,6 +340,7 @@ namespace System.Net.Http.QPack
             return true;
         }
 
+        // TODO these are fairly hard coded for the first two bytes to be zero.
         public bool BeginEncode(IEnumerable<KeyValuePair<string, string>> headers, Span<byte> buffer, out int length)
         {
             _enumerator = headers.GetEnumerator();
@@ -350,11 +351,7 @@ namespace System.Net.Http.QPack
             buffer[0] = 0;
             buffer[1] = 0;
 
-            bool doneEncode = Encode(buffer.Slice(2), out length);
-
-            // Add two for the first two bytes.
-            length += 2;
-            return doneEncode;
+            return Encode(buffer.Slice(2), out length);
         }
 
         public bool BeginEncode(int statusCode, IEnumerable<KeyValuePair<string, string>> headers, Span<byte> buffer, out int length)
diff --git a/src/Shared/runtime/Quic/Implementations/MsQuic/Internal/MsQuicApi.cs b/src/Shared/runtime/Quic/Implementations/MsQuic/Internal/MsQuicApi.cs
index fb6330c..30e5cba 100644
--- a/src/Shared/runtime/Quic/Implementations/MsQuic/Internal/MsQuicApi.cs
+++ b/src/Shared/runtime/Quic/Implementations/MsQuic/Internal/MsQuicApi.cs
@@ -1,4 +1,4 @@
-// Licensed to the .NET Foundation under one or more agreements.
+?// Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
@@ -143,6 +143,12 @@ namespace System.Net.Quic.Implementations.MsQuic.Internal
 
             OperatingSystem ver = Environment.OSVersion;
 
+            if (ver.Platform == PlatformID.Win32NT && ver.Version < new Version(10, 0, 19041, 0))
+            {
+                IsQuicSupported = false;
+                return;
+            }
+
             // TODO: try to initialize TLS 1.3 in SslStream.
 
             try

Copy link
Contributor

The shared code is out of sync.

The Diff
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/runtime/Http2/Hpack/HPackEncoder.cs
	modified:   src/Shared/runtime/Http3/QPack/QPackEncoder.cs

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/runtime/Http2/Hpack/HPackEncoder.cs b/src/Shared/runtime/Http2/Hpack/HPackEncoder.cs
index 5c0bbecf..dab58814 100644
--- a/src/Shared/runtime/Http2/Hpack/HPackEncoder.cs
+++ b/src/Shared/runtime/Http2/Hpack/HPackEncoder.cs
@@ -285,12 +285,7 @@ namespace System.Net.Http.HPack
         }
 
         /// <summary>Encodes a "Literal Header Field without Indexing - New Name".</summary>
-        public static bool EncodeLiteralHeaderFieldWithoutIndexingNewName(string name, ReadOnlySpan<string> values, string separator, Span<byte> destination, out int bytesWritten)
-        {
-            return EncodeLiteralHeaderFieldWithoutIndexingNewName(name, values, separator, valueEncoding: null, destination, out bytesWritten);
-        }
-
-        public static bool EncodeLiteralHeaderFieldWithoutIndexingNewName(string name, ReadOnlySpan<string> values, string separator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
+        public static bool EncodeLiteralHeaderFieldWithoutIndexingNewName(string name, ReadOnlySpan<string> values, byte[] separator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
         {
             // From https://tools.ietf.org/html/rfc7541#section-6.2.2
             // ------------------------------------------------------
@@ -515,12 +510,7 @@ namespace System.Net.Http.HPack
             return false;
         }
 
-        public static bool EncodeStringLiterals(ReadOnlySpan<string> values, string? separator, Span<byte> destination, out int bytesWritten)
-        {
-            return EncodeStringLiterals(values, separator, valueEncoding: null, destination, out bytesWritten);
-        }
-
-        public static bool EncodeStringLiterals(ReadOnlySpan<string> values, string? separator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
+        public static bool EncodeStringLiterals(ReadOnlySpan<string> values, byte[]? separator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
         {
             bytesWritten = 0;
 
@@ -536,23 +526,22 @@ namespace System.Net.Http.HPack
             if (destination.Length != 0)
             {
                 Debug.Assert(separator != null);
-                int valueLength;
+                Debug.Assert(Ascii.IsValid(separator));
+                int valueLength = checked((values.Length - 1) * separator.Length);
 
-                // Calculate length of all parts and separators.
+                // Calculate length of all values.
                 if (valueEncoding is null || ReferenceEquals(valueEncoding, Encoding.Latin1))
                 {
-                    valueLength = checked((int)(values.Length - 1) * separator.Length);
                     foreach (string part in values)
                     {
-                        valueLength = checked((int)(valueLength + part.Length));
+                        valueLength = checked(valueLength + part.Length);
                     }
                 }
                 else
                 {
-                    valueLength = checked((int)(values.Length - 1) * valueEncoding.GetByteCount(separator));
                     foreach (string part in values)
                     {
-                        valueLength = checked((int)(valueLength + valueEncoding.GetByteCount(part)));
+                        valueLength = checked(valueLength + valueEncoding.GetByteCount(part));
                     }
                 }
 
@@ -571,7 +560,7 @@ namespace System.Net.Http.HPack
 
                             for (int i = 1; i < values.Length; i++)
                             {
-                                EncodeValueStringPart(separator, destination);
+                                separator.CopyTo(destination);
                                 destination = destination.Slice(separator.Length);
 
                                 value = values[i];
@@ -586,8 +575,8 @@ namespace System.Net.Http.HPack
 
                             for (int i = 1; i < values.Length; i++)
                             {
-                                written = valueEncoding.GetBytes(separator, destination);
-                                destination = destination.Slice(written);
+                                separator.CopyTo(destination);
+                                destination = destination.Slice(separator.Length);
 
                                 written = valueEncoding.GetBytes(values[i], destination);
                                 destination = destination.Slice(written);
diff --git a/src/Shared/runtime/Http3/QPack/QPackEncoder.cs b/src/Shared/runtime/Http3/QPack/QPackEncoder.cs
index aa951b24..5d96530b 100644
--- a/src/Shared/runtime/Http3/QPack/QPackEncoder.cs
+++ b/src/Shared/runtime/Http3/QPack/QPackEncoder.cs
@@ -144,14 +144,9 @@ namespace System.Net.Http.QPack
         /// <summary>
         /// Encodes a Literal Header Field Without Name Reference, building the value by concatenating a collection of strings with separators.
         /// </summary>
-        public static bool EncodeLiteralHeaderFieldWithoutNameReference(string name, ReadOnlySpan<string> values, string valueSeparator, Span<byte> destination, out int bytesWritten)
+        public static bool EncodeLiteralHeaderFieldWithoutNameReference(string name, ReadOnlySpan<string> values, byte[] separator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
         {
-            return EncodeLiteralHeaderFieldWithoutNameReference(name, values, valueSeparator, valueEncoding: null, destination, out bytesWritten);
-        }
-
-        public static bool EncodeLiteralHeaderFieldWithoutNameReference(string name, ReadOnlySpan<string> values, string valueSeparator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
-        {
-            if (EncodeNameString(name, destination, out int nameLength) && EncodeValueString(values, valueSeparator, valueEncoding, destination.Slice(nameLength), out int valueLength))
+            if (EncodeNameString(name, destination, out int nameLength) && EncodeValueString(values, separator, valueEncoding, destination.Slice(nameLength), out int valueLength))
             {
                 bytesWritten = nameLength + valueLength;
                 return true;
@@ -222,12 +217,7 @@ namespace System.Net.Http.QPack
         /// <summary>
         /// Encodes a value by concatenating a collection of strings, separated by a separator string.
         /// </summary>
-        public static bool EncodeValueString(ReadOnlySpan<string> values, string? separator, Span<byte> buffer, out int length)
-        {
-            return EncodeValueString(values, separator, valueEncoding: null, buffer, out length);
-        }
-
-        public static bool EncodeValueString(ReadOnlySpan<string> values, string? separator, Encoding? valueEncoding, Span<byte> buffer, out int length)
+        public static bool EncodeValueString(ReadOnlySpan<string> values, byte[]? separator, Encoding? valueEncoding, Span<byte> buffer, out int length)
         {
             if (values.Length == 1)
             {
@@ -243,10 +233,11 @@ namespace System.Net.Http.QPack
             if (buffer.Length > 0)
             {
                 Debug.Assert(separator != null);
-                int valueLength;
+                Debug.Assert(Ascii.IsValid(separator));
+                int valueLength = separator.Length * (values.Length - 1);
+
                 if (valueEncoding is null || ReferenceEquals(valueEncoding, Encoding.Latin1))
                 {
-                    valueLength = separator.Length * (values.Length - 1);
                     foreach (string part in values)
                     {
                         valueLength += part.Length;
@@ -254,7 +245,6 @@ namespace System.Net.Http.QPack
                 }
                 else
                 {
-                    valueLength = valueEncoding.GetByteCount(separator) * (values.Length - 1);
                     foreach (string part in values)
                     {
                         valueLength += valueEncoding.GetByteCount(part);
@@ -275,7 +265,7 @@ namespace System.Net.Http.QPack
 
                             for (int i = 1; i < values.Length; i++)
                             {
-                                EncodeValueStringPart(separator, buffer);
+                                separator.CopyTo(buffer);
                                 buffer = buffer.Slice(separator.Length);
 
                                 value = values[i];
@@ -290,8 +280,8 @@ namespace System.Net.Http.QPack
 
                             for (int i = 1; i < values.Length; i++)
                             {
-                                written = valueEncoding.GetBytes(separator, buffer);
-                                buffer = buffer.Slice(written);
+                                separator.CopyTo(buffer);
+                                buffer = buffer.Slice(separator.Length);
 
                                 written = valueEncoding.GetBytes(values[i], buffer);
                                 buffer = buffer.Slice(written);

Copy link
Contributor

The shared code is out of sync.

The Diff
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/runtime/Http2/Hpack/HPackEncoder.cs
	modified:   src/Shared/runtime/Http3/QPack/QPackEncoder.cs

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/runtime/Http2/Hpack/HPackEncoder.cs b/src/Shared/runtime/Http2/Hpack/HPackEncoder.cs
index 5c0bbecf..dab58814 100644
--- a/src/Shared/runtime/Http2/Hpack/HPackEncoder.cs
+++ b/src/Shared/runtime/Http2/Hpack/HPackEncoder.cs
@@ -285,12 +285,7 @@ namespace System.Net.Http.HPack
         }
 
         /// <summary>Encodes a "Literal Header Field without Indexing - New Name".</summary>
-        public static bool EncodeLiteralHeaderFieldWithoutIndexingNewName(string name, ReadOnlySpan<string> values, string separator, Span<byte> destination, out int bytesWritten)
-        {
-            return EncodeLiteralHeaderFieldWithoutIndexingNewName(name, values, separator, valueEncoding: null, destination, out bytesWritten);
-        }
-
-        public static bool EncodeLiteralHeaderFieldWithoutIndexingNewName(string name, ReadOnlySpan<string> values, string separator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
+        public static bool EncodeLiteralHeaderFieldWithoutIndexingNewName(string name, ReadOnlySpan<string> values, byte[] separator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
         {
             // From https://tools.ietf.org/html/rfc7541#section-6.2.2
             // ------------------------------------------------------
@@ -515,12 +510,7 @@ namespace System.Net.Http.HPack
             return false;
         }
 
-        public static bool EncodeStringLiterals(ReadOnlySpan<string> values, string? separator, Span<byte> destination, out int bytesWritten)
-        {
-            return EncodeStringLiterals(values, separator, valueEncoding: null, destination, out bytesWritten);
-        }
-
-        public static bool EncodeStringLiterals(ReadOnlySpan<string> values, string? separator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
+        public static bool EncodeStringLiterals(ReadOnlySpan<string> values, byte[]? separator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
         {
             bytesWritten = 0;
 
@@ -536,23 +526,22 @@ namespace System.Net.Http.HPack
             if (destination.Length != 0)
             {
                 Debug.Assert(separator != null);
-                int valueLength;
+                Debug.Assert(Ascii.IsValid(separator));
+                int valueLength = checked((values.Length - 1) * separator.Length);
 
-                // Calculate length of all parts and separators.
+                // Calculate length of all values.
                 if (valueEncoding is null || ReferenceEquals(valueEncoding, Encoding.Latin1))
                 {
-                    valueLength = checked((int)(values.Length - 1) * separator.Length);
                     foreach (string part in values)
                     {
-                        valueLength = checked((int)(valueLength + part.Length));
+                        valueLength = checked(valueLength + part.Length);
                     }
                 }
                 else
                 {
-                    valueLength = checked((int)(values.Length - 1) * valueEncoding.GetByteCount(separator));
                     foreach (string part in values)
                     {
-                        valueLength = checked((int)(valueLength + valueEncoding.GetByteCount(part)));
+                        valueLength = checked(valueLength + valueEncoding.GetByteCount(part));
                     }
                 }
 
@@ -571,7 +560,7 @@ namespace System.Net.Http.HPack
 
                             for (int i = 1; i < values.Length; i++)
                             {
-                                EncodeValueStringPart(separator, destination);
+                                separator.CopyTo(destination);
                                 destination = destination.Slice(separator.Length);
 
                                 value = values[i];
@@ -586,8 +575,8 @@ namespace System.Net.Http.HPack
 
                             for (int i = 1; i < values.Length; i++)
                             {
-                                written = valueEncoding.GetBytes(separator, destination);
-                                destination = destination.Slice(written);
+                                separator.CopyTo(destination);
+                                destination = destination.Slice(separator.Length);
 
                                 written = valueEncoding.GetBytes(values[i], destination);
                                 destination = destination.Slice(written);
diff --git a/src/Shared/runtime/Http3/QPack/QPackEncoder.cs b/src/Shared/runtime/Http3/QPack/QPackEncoder.cs
index aa951b24..5d96530b 100644
--- a/src/Shared/runtime/Http3/QPack/QPackEncoder.cs
+++ b/src/Shared/runtime/Http3/QPack/QPackEncoder.cs
@@ -144,14 +144,9 @@ namespace System.Net.Http.QPack
         /// <summary>
         /// Encodes a Literal Header Field Without Name Reference, building the value by concatenating a collection of strings with separators.
         /// </summary>
-        public static bool EncodeLiteralHeaderFieldWithoutNameReference(string name, ReadOnlySpan<string> values, string valueSeparator, Span<byte> destination, out int bytesWritten)
+        public static bool EncodeLiteralHeaderFieldWithoutNameReference(string name, ReadOnlySpan<string> values, byte[] separator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
         {
-            return EncodeLiteralHeaderFieldWithoutNameReference(name, values, valueSeparator, valueEncoding: null, destination, out bytesWritten);
-        }
-
-        public static bool EncodeLiteralHeaderFieldWithoutNameReference(string name, ReadOnlySpan<string> values, string valueSeparator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
-        {
-            if (EncodeNameString(name, destination, out int nameLength) && EncodeValueString(values, valueSeparator, valueEncoding, destination.Slice(nameLength), out int valueLength))
+            if (EncodeNameString(name, destination, out int nameLength) && EncodeValueString(values, separator, valueEncoding, destination.Slice(nameLength), out int valueLength))
             {
                 bytesWritten = nameLength + valueLength;
                 return true;
@@ -222,12 +217,7 @@ namespace System.Net.Http.QPack
         /// <summary>
         /// Encodes a value by concatenating a collection of strings, separated by a separator string.
         /// </summary>
-        public static bool EncodeValueString(ReadOnlySpan<string> values, string? separator, Span<byte> buffer, out int length)
-        {
-            return EncodeValueString(values, separator, valueEncoding: null, buffer, out length);
-        }
-
-        public static bool EncodeValueString(ReadOnlySpan<string> values, string? separator, Encoding? valueEncoding, Span<byte> buffer, out int length)
+        public static bool EncodeValueString(ReadOnlySpan<string> values, byte[]? separator, Encoding? valueEncoding, Span<byte> buffer, out int length)
         {
             if (values.Length == 1)
             {
@@ -243,10 +233,11 @@ namespace System.Net.Http.QPack
             if (buffer.Length > 0)
             {
                 Debug.Assert(separator != null);
-                int valueLength;
+                Debug.Assert(Ascii.IsValid(separator));
+                int valueLength = separator.Length * (values.Length - 1);
+
                 if (valueEncoding is null || ReferenceEquals(valueEncoding, Encoding.Latin1))
                 {
-                    valueLength = separator.Length * (values.Length - 1);
                     foreach (string part in values)
                     {
                         valueLength += part.Length;
@@ -254,7 +245,6 @@ namespace System.Net.Http.QPack
                 }
                 else
                 {
-                    valueLength = valueEncoding.GetByteCount(separator) * (values.Length - 1);
                     foreach (string part in values)
                     {
                         valueLength += valueEncoding.GetByteCount(part);
@@ -275,7 +265,7 @@ namespace System.Net.Http.QPack
 
                             for (int i = 1; i < values.Length; i++)
                             {
-                                EncodeValueStringPart(separator, buffer);
+                                separator.CopyTo(buffer);
                                 buffer = buffer.Slice(separator.Length);
 
                                 value = values[i];
@@ -290,8 +280,8 @@ namespace System.Net.Http.QPack
 
                             for (int i = 1; i < values.Length; i++)
                             {
-                                written = valueEncoding.GetBytes(separator, buffer);
-                                buffer = buffer.Slice(written);
+                                separator.CopyTo(buffer);
+                                buffer = buffer.Slice(separator.Length);
 
                                 written = valueEncoding.GetBytes(values[i], buffer);
                                 buffer = buffer.Slice(written);

1 similar comment
Copy link
Contributor

The shared code is out of sync.

The Diff
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/runtime/Http2/Hpack/HPackEncoder.cs
	modified:   src/Shared/runtime/Http3/QPack/QPackEncoder.cs

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/runtime/Http2/Hpack/HPackEncoder.cs b/src/Shared/runtime/Http2/Hpack/HPackEncoder.cs
index 5c0bbecf..dab58814 100644
--- a/src/Shared/runtime/Http2/Hpack/HPackEncoder.cs
+++ b/src/Shared/runtime/Http2/Hpack/HPackEncoder.cs
@@ -285,12 +285,7 @@ namespace System.Net.Http.HPack
         }
 
         /// <summary>Encodes a "Literal Header Field without Indexing - New Name".</summary>
-        public static bool EncodeLiteralHeaderFieldWithoutIndexingNewName(string name, ReadOnlySpan<string> values, string separator, Span<byte> destination, out int bytesWritten)
-        {
-            return EncodeLiteralHeaderFieldWithoutIndexingNewName(name, values, separator, valueEncoding: null, destination, out bytesWritten);
-        }
-
-        public static bool EncodeLiteralHeaderFieldWithoutIndexingNewName(string name, ReadOnlySpan<string> values, string separator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
+        public static bool EncodeLiteralHeaderFieldWithoutIndexingNewName(string name, ReadOnlySpan<string> values, byte[] separator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
         {
             // From https://tools.ietf.org/html/rfc7541#section-6.2.2
             // ------------------------------------------------------
@@ -515,12 +510,7 @@ namespace System.Net.Http.HPack
             return false;
         }
 
-        public static bool EncodeStringLiterals(ReadOnlySpan<string> values, string? separator, Span<byte> destination, out int bytesWritten)
-        {
-            return EncodeStringLiterals(values, separator, valueEncoding: null, destination, out bytesWritten);
-        }
-
-        public static bool EncodeStringLiterals(ReadOnlySpan<string> values, string? separator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
+        public static bool EncodeStringLiterals(ReadOnlySpan<string> values, byte[]? separator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
         {
             bytesWritten = 0;
 
@@ -536,23 +526,22 @@ namespace System.Net.Http.HPack
             if (destination.Length != 0)
             {
                 Debug.Assert(separator != null);
-                int valueLength;
+                Debug.Assert(Ascii.IsValid(separator));
+                int valueLength = checked((values.Length - 1) * separator.Length);
 
-                // Calculate length of all parts and separators.
+                // Calculate length of all values.
                 if (valueEncoding is null || ReferenceEquals(valueEncoding, Encoding.Latin1))
                 {
-                    valueLength = checked((int)(values.Length - 1) * separator.Length);
                     foreach (string part in values)
                     {
-                        valueLength = checked((int)(valueLength + part.Length));
+                        valueLength = checked(valueLength + part.Length);
                     }
                 }
                 else
                 {
-                    valueLength = checked((int)(values.Length - 1) * valueEncoding.GetByteCount(separator));
                     foreach (string part in values)
                     {
-                        valueLength = checked((int)(valueLength + valueEncoding.GetByteCount(part)));
+                        valueLength = checked(valueLength + valueEncoding.GetByteCount(part));
                     }
                 }
 
@@ -571,7 +560,7 @@ namespace System.Net.Http.HPack
 
                             for (int i = 1; i < values.Length; i++)
                             {
-                                EncodeValueStringPart(separator, destination);
+                                separator.CopyTo(destination);
                                 destination = destination.Slice(separator.Length);
 
                                 value = values[i];
@@ -586,8 +575,8 @@ namespace System.Net.Http.HPack
 
                             for (int i = 1; i < values.Length; i++)
                             {
-                                written = valueEncoding.GetBytes(separator, destination);
-                                destination = destination.Slice(written);
+                                separator.CopyTo(destination);
+                                destination = destination.Slice(separator.Length);
 
                                 written = valueEncoding.GetBytes(values[i], destination);
                                 destination = destination.Slice(written);
diff --git a/src/Shared/runtime/Http3/QPack/QPackEncoder.cs b/src/Shared/runtime/Http3/QPack/QPackEncoder.cs
index aa951b24..5d96530b 100644
--- a/src/Shared/runtime/Http3/QPack/QPackEncoder.cs
+++ b/src/Shared/runtime/Http3/QPack/QPackEncoder.cs
@@ -144,14 +144,9 @@ namespace System.Net.Http.QPack
         /// <summary>
         /// Encodes a Literal Header Field Without Name Reference, building the value by concatenating a collection of strings with separators.
         /// </summary>
-        public static bool EncodeLiteralHeaderFieldWithoutNameReference(string name, ReadOnlySpan<string> values, string valueSeparator, Span<byte> destination, out int bytesWritten)
+        public static bool EncodeLiteralHeaderFieldWithoutNameReference(string name, ReadOnlySpan<string> values, byte[] separator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
         {
-            return EncodeLiteralHeaderFieldWithoutNameReference(name, values, valueSeparator, valueEncoding: null, destination, out bytesWritten);
-        }
-
-        public static bool EncodeLiteralHeaderFieldWithoutNameReference(string name, ReadOnlySpan<string> values, string valueSeparator, Encoding? valueEncoding, Span<byte> destination, out int bytesWritten)
-        {
-            if (EncodeNameString(name, destination, out int nameLength) && EncodeValueString(values, valueSeparator, valueEncoding, destination.Slice(nameLength), out int valueLength))
+            if (EncodeNameString(name, destination, out int nameLength) && EncodeValueString(values, separator, valueEncoding, destination.Slice(nameLength), out int valueLength))
             {
                 bytesWritten = nameLength + valueLength;
                 return true;
@@ -222,12 +217,7 @@ namespace System.Net.Http.QPack
         /// <summary>
         /// Encodes a value by concatenating a collection of strings, separated by a separator string.
         /// </summary>
-        public static bool EncodeValueString(ReadOnlySpan<string> values, string? separator, Span<byte> buffer, out int length)
-        {
-            return EncodeValueString(values, separator, valueEncoding: null, buffer, out length);
-        }
-
-        public static bool EncodeValueString(ReadOnlySpan<string> values, string? separator, Encoding? valueEncoding, Span<byte> buffer, out int length)
+        public static bool EncodeValueString(ReadOnlySpan<string> values, byte[]? separator, Encoding? valueEncoding, Span<byte> buffer, out int length)
         {
             if (values.Length == 1)
             {
@@ -243,10 +233,11 @@ namespace System.Net.Http.QPack
             if (buffer.Length > 0)
             {
                 Debug.Assert(separator != null);
-                int valueLength;
+                Debug.Assert(Ascii.IsValid(separator));
+                int valueLength = separator.Length * (values.Length - 1);
+
                 if (valueEncoding is null || ReferenceEquals(valueEncoding, Encoding.Latin1))
                 {
-                    valueLength = separator.Length * (values.Length - 1);
                     foreach (string part in values)
                     {
                         valueLength += part.Length;
@@ -254,7 +245,6 @@ namespace System.Net.Http.QPack
                 }
                 else
                 {
-                    valueLength = valueEncoding.GetByteCount(separator) * (values.Length - 1);
                     foreach (string part in values)
                     {
                         valueLength += valueEncoding.GetByteCount(part);
@@ -275,7 +265,7 @@ namespace System.Net.Http.QPack
 
                             for (int i = 1; i < values.Length; i++)
                             {
-                                EncodeValueStringPart(separator, buffer);
+                                separator.CopyTo(buffer);
                                 buffer = buffer.Slice(separator.Length);
 
                                 value = values[i];
@@ -290,8 +280,8 @@ namespace System.Net.Http.QPack
 
                             for (int i = 1; i < values.Length; i++)
                             {
-                                written = valueEncoding.GetBytes(separator, buffer);
-                                buffer = buffer.Slice(written);
+                                separator.CopyTo(buffer);
+                                buffer = buffer.Slice(separator.Length);
 
                                 written = valueEncoding.GetBytes(values[i], buffer);
                                 buffer = buffer.Slice(written);

Copy link
Contributor

The shared code is out of sync.

The Diff
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/runtime/Http3/Frames/Http3ErrorCode.cs

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/runtime/Http3/Frames/Http3ErrorCode.cs b/src/Shared/runtime/Http3/Frames/Http3ErrorCode.cs
index fdfe04ce..ebaa96f1 100644
--- a/src/Shared/runtime/Http3/Frames/Http3ErrorCode.cs
+++ b/src/Shared/runtime/Http3/Frames/Http3ErrorCode.cs
@@ -91,5 +91,20 @@ namespace System.Net.Http
         /// The requested operation cannot be served over HTTP/3. The peer should retry over HTTP/1.1.
         /// </summary>
         VersionFallback = 0x110,
+        /// <summary>
+        /// H3_QPACK_DECOMPRESSION_FAILED (0x200):
+        /// The decoder failed to interpret an encoded field section and is not able to continue decoding that field section.
+        /// </summary>
+        QPackDecompressionFailed = 0x200,
+        /// <summary>
+        /// H3_QPACK_ENCODER_STREAM_ERROR (0x201):
+        /// The decoder failed to interpret an encoder instruction received on the encoder stream.
+        /// </summary>
+        QPackEncoderStreamError = 0x201,
+        /// <summary>
+        /// H3_QPACK_DECODER_STREAM_ERROR (0x202):
+        /// The encoder failed to interpret an decoder instruction received on the decoder stream.
+        /// </summary>
+        QPackDecoderStreamError = 0x202,
     }
 }

Copy link
Contributor

The shared code is out of sync.

The Diff
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs b/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs
index ff141b84..28e7a971 100644
--- a/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs
+++ b/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs
@@ -87,10 +87,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             .Concat(_headerValueHuffmanBytes)
             .ToArray();
 
-        private static readonly byte[] _literalEmptyString = new byte[] { 0x00 };
-
-        private static readonly byte[] _literalEmptyStringHuffman = new byte[] { 0x80 };
-
         // &        *
         // 11111000 11111111
         private static readonly byte[] _huffmanLongPadding = new byte[] { 0x82, 0xf8, 0xff };
@@ -247,43 +243,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             TestDecodeWithoutIndexing(encoded, _headerNameString, _headerValueString);
         }
 
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_EmptyName()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_literalEmptyString)
-                .Concat(_headerValue)
-                .ToArray();
-
-            HPackDecodingException exception = Assert.Throws<HPackDecodingException>(() => _decoder.Decode(encoded, endHeaders: true, handler: _handler));
-            Assert.Equal(SR.Format(SR.net_http_invalid_header_name, string.Empty), exception.Message);
-            Assert.Empty(_handler.DecodedHeaders);
-        }
-
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_EmptyValue()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_headerName)
-                .Concat(_literalEmptyString)
-                .ToArray();
-
-            TestDecodeWithoutIndexing(encoded, _headerNameString, string.Empty);
-        }
-
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_EmptyNameAndValue()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_literalEmptyString)
-                .Concat(_literalEmptyString)
-                .ToArray();
-
-            HPackDecodingException exception = Assert.Throws<HPackDecodingException>(() => _decoder.Decode(encoded, endHeaders: true, handler: _handler));
-            Assert.Equal(SR.Format(SR.net_http_invalid_header_name, string.Empty), exception.Message);
-            Assert.Empty(_handler.DecodedHeaders);
-        }
-
         [Fact]
         public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedName()
         {
@@ -295,19 +254,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             TestDecodeWithoutIndexing(encoded, _headerNameString, _headerValueString);
         }
 
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedName_Empty()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_literalEmptyStringHuffman)
-                .Concat(_headerValue)
-                .ToArray();
-
-            HPackDecodingException exception = Assert.Throws<HPackDecodingException>(() => _decoder.Decode(encoded, endHeaders: true, handler: _handler));
-            Assert.Equal(SR.Format(SR.net_http_invalid_header_name, string.Empty), exception.Message);
-            Assert.Empty(_handler.DecodedHeaders);
-        }
-
         [Fact]
         public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedValue()
         {
@@ -319,17 +265,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             TestDecodeWithoutIndexing(encoded, _headerNameString, _headerValueString);
         }
 
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedValue_Empty()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_headerName)
-                .Concat(_literalEmptyStringHuffman)
-                .ToArray();
-
-            TestDecodeWithoutIndexing(encoded, _headerNameString, string.Empty);
-        }
-
         [Fact]
         public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedNameAndValue()
         {
@@ -341,19 +276,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             TestDecodeWithoutIndexing(encoded, _headerNameString, _headerValueString);
         }
 
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedNameAndValue_Empty()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_literalEmptyStringHuffman)
-                .Concat(_literalEmptyStringHuffman)
-                .ToArray();
-
-            HPackDecodingException exception = Assert.Throws<HPackDecodingException>(() => _decoder.Decode(encoded, endHeaders: true, handler: _handler));
-            Assert.Equal(SR.Format(SR.net_http_invalid_header_name, string.Empty), exception.Message);
-            Assert.Empty(_handler.DecodedHeaders);
-        }
-
         [Fact]
         public void DecodesLiteralHeaderFieldWithoutIndexing_IndexedName()
         {

Copy link
Contributor

github-actions bot commented Aug 1, 2024

The shared code is out of sync.

The Diff
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs b/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs
index ff141b84..28e7a971 100644
--- a/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs
+++ b/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs
@@ -87,10 +87,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             .Concat(_headerValueHuffmanBytes)
             .ToArray();
 
-        private static readonly byte[] _literalEmptyString = new byte[] { 0x00 };
-
-        private static readonly byte[] _literalEmptyStringHuffman = new byte[] { 0x80 };
-
         // &        *
         // 11111000 11111111
         private static readonly byte[] _huffmanLongPadding = new byte[] { 0x82, 0xf8, 0xff };
@@ -247,43 +243,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             TestDecodeWithoutIndexing(encoded, _headerNameString, _headerValueString);
         }
 
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_EmptyName()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_literalEmptyString)
-                .Concat(_headerValue)
-                .ToArray();
-
-            HPackDecodingException exception = Assert.Throws<HPackDecodingException>(() => _decoder.Decode(encoded, endHeaders: true, handler: _handler));
-            Assert.Equal(SR.Format(SR.net_http_invalid_header_name, string.Empty), exception.Message);
-            Assert.Empty(_handler.DecodedHeaders);
-        }
-
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_EmptyValue()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_headerName)
-                .Concat(_literalEmptyString)
-                .ToArray();
-
-            TestDecodeWithoutIndexing(encoded, _headerNameString, string.Empty);
-        }
-
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_EmptyNameAndValue()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_literalEmptyString)
-                .Concat(_literalEmptyString)
-                .ToArray();
-
-            HPackDecodingException exception = Assert.Throws<HPackDecodingException>(() => _decoder.Decode(encoded, endHeaders: true, handler: _handler));
-            Assert.Equal(SR.Format(SR.net_http_invalid_header_name, string.Empty), exception.Message);
-            Assert.Empty(_handler.DecodedHeaders);
-        }
-
         [Fact]
         public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedName()
         {
@@ -295,19 +254,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             TestDecodeWithoutIndexing(encoded, _headerNameString, _headerValueString);
         }
 
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedName_Empty()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_literalEmptyStringHuffman)
-                .Concat(_headerValue)
-                .ToArray();
-
-            HPackDecodingException exception = Assert.Throws<HPackDecodingException>(() => _decoder.Decode(encoded, endHeaders: true, handler: _handler));
-            Assert.Equal(SR.Format(SR.net_http_invalid_header_name, string.Empty), exception.Message);
-            Assert.Empty(_handler.DecodedHeaders);
-        }
-
         [Fact]
         public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedValue()
         {
@@ -319,17 +265,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             TestDecodeWithoutIndexing(encoded, _headerNameString, _headerValueString);
         }
 
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedValue_Empty()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_headerName)
-                .Concat(_literalEmptyStringHuffman)
-                .ToArray();
-
-            TestDecodeWithoutIndexing(encoded, _headerNameString, string.Empty);
-        }
-
         [Fact]
         public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedNameAndValue()
         {
@@ -341,19 +276,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             TestDecodeWithoutIndexing(encoded, _headerNameString, _headerValueString);
         }
 
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedNameAndValue_Empty()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_literalEmptyStringHuffman)
-                .Concat(_literalEmptyStringHuffman)
-                .ToArray();
-
-            HPackDecodingException exception = Assert.Throws<HPackDecodingException>(() => _decoder.Decode(encoded, endHeaders: true, handler: _handler));
-            Assert.Equal(SR.Format(SR.net_http_invalid_header_name, string.Empty), exception.Message);
-            Assert.Empty(_handler.DecodedHeaders);
-        }
-
         [Fact]
         public void DecodesLiteralHeaderFieldWithoutIndexing_IndexedName()
         {

@amcasey
Copy link
Member

amcasey commented Aug 1, 2024

dotnet/runtime#105765

Copy link
Contributor

github-actions bot commented Aug 2, 2024

The shared code is out of sync.

The Diff
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs b/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs
index ff141b84..28e7a971 100644
--- a/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs
+++ b/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs
@@ -87,10 +87,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             .Concat(_headerValueHuffmanBytes)
             .ToArray();
 
-        private static readonly byte[] _literalEmptyString = new byte[] { 0x00 };
-
-        private static readonly byte[] _literalEmptyStringHuffman = new byte[] { 0x80 };
-
         // &        *
         // 11111000 11111111
         private static readonly byte[] _huffmanLongPadding = new byte[] { 0x82, 0xf8, 0xff };
@@ -247,43 +243,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             TestDecodeWithoutIndexing(encoded, _headerNameString, _headerValueString);
         }
 
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_EmptyName()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_literalEmptyString)
-                .Concat(_headerValue)
-                .ToArray();
-
-            HPackDecodingException exception = Assert.Throws<HPackDecodingException>(() => _decoder.Decode(encoded, endHeaders: true, handler: _handler));
-            Assert.Equal(SR.Format(SR.net_http_invalid_header_name, string.Empty), exception.Message);
-            Assert.Empty(_handler.DecodedHeaders);
-        }
-
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_EmptyValue()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_headerName)
-                .Concat(_literalEmptyString)
-                .ToArray();
-
-            TestDecodeWithoutIndexing(encoded, _headerNameString, string.Empty);
-        }
-
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_EmptyNameAndValue()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_literalEmptyString)
-                .Concat(_literalEmptyString)
-                .ToArray();
-
-            HPackDecodingException exception = Assert.Throws<HPackDecodingException>(() => _decoder.Decode(encoded, endHeaders: true, handler: _handler));
-            Assert.Equal(SR.Format(SR.net_http_invalid_header_name, string.Empty), exception.Message);
-            Assert.Empty(_handler.DecodedHeaders);
-        }
-
         [Fact]
         public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedName()
         {
@@ -295,19 +254,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             TestDecodeWithoutIndexing(encoded, _headerNameString, _headerValueString);
         }
 
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedName_Empty()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_literalEmptyStringHuffman)
-                .Concat(_headerValue)
-                .ToArray();
-
-            HPackDecodingException exception = Assert.Throws<HPackDecodingException>(() => _decoder.Decode(encoded, endHeaders: true, handler: _handler));
-            Assert.Equal(SR.Format(SR.net_http_invalid_header_name, string.Empty), exception.Message);
-            Assert.Empty(_handler.DecodedHeaders);
-        }
-
         [Fact]
         public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedValue()
         {
@@ -319,17 +265,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             TestDecodeWithoutIndexing(encoded, _headerNameString, _headerValueString);
         }
 
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedValue_Empty()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_headerName)
-                .Concat(_literalEmptyStringHuffman)
-                .ToArray();
-
-            TestDecodeWithoutIndexing(encoded, _headerNameString, string.Empty);
-        }
-
         [Fact]
         public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedNameAndValue()
         {
@@ -341,19 +276,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             TestDecodeWithoutIndexing(encoded, _headerNameString, _headerValueString);
         }
 
-        [Fact]
-        public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedNameAndValue_Empty()
-        {
-            byte[] encoded = _literalHeaderFieldWithoutIndexingNewName
-                .Concat(_literalEmptyStringHuffman)
-                .Concat(_literalEmptyStringHuffman)
-                .ToArray();
-
-            HPackDecodingException exception = Assert.Throws<HPackDecodingException>(() => _decoder.Decode(encoded, endHeaders: true, handler: _handler));
-            Assert.Equal(SR.Format(SR.net_http_invalid_header_name, string.Empty), exception.Message);
-            Assert.Empty(_handler.DecodedHeaders);
-        }
-
         [Fact]
         public void DecodesLiteralHeaderFieldWithoutIndexing_IndexedName()
         {

Copy link
Contributor

The shared code is out of sync.

The Diff
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs b/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs
index 2dde5440..ff141b84 100644
--- a/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs
+++ b/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs
@@ -151,25 +151,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             Assert.Equal(_headerValueString, _handler.DecodedHeaders[_headerNameString]);
         }
 
-        [Fact]
-        public void DecodesIndexedHeaderField_DynamicTable_ReferencedEntryRemovedOnInsertion()
-        {
-            // Pre-populate the dynamic table so we'll have something to reference.
-            // This entry will have index 62 (0x3E).
-            _dynamicTable.Insert(_headerNameBytes, _headerValueBytes);
-            Assert.Equal(1, _dynamicTable.Count);
-
-            Assert.InRange(_dynamicTable.MaxSize, 1, _literalHeaderNameBytes.Length); // Assert that our string will be too big
-
-            byte[] encoded = (new byte[] { 0x40 | 0x3E }) // Indexing enabled (0x40) | dynamic table (62 = 0x3E) as a 6-integer, 
-                .Concat(_literalHeaderName) // A header value that's too large to fit in the dynamic table
-                .ToArray();
-
-            _decoder.Decode(encoded, endHeaders: true, handler: _handler);
-            Assert.Equal(0, _dynamicTable.Count); // The large entry caused the table to be wiped
-            Assert.Equal(_literalHeaderNameString, _handler.DecodedHeaders[_headerNameString]); // but we got the header anyway
-        }
-
         [Fact]
         public void DecodesIndexedHeaderField_OutOfRange_Error()
         {

Copy link
Contributor

The shared code is out of sync.

The Diff
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs

no changes added to commit (use "git add" and/or "git commit -a")

diff --git a/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs b/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs
index 2dde5440..ff141b84 100644
--- a/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs
+++ b/src/Shared/test/Shared.Tests/runtime/Http2/HPackDecoderTest.cs
@@ -151,25 +151,6 @@ namespace System.Net.Http.Unit.Tests.HPack
             Assert.Equal(_headerValueString, _handler.DecodedHeaders[_headerNameString]);
         }
 
-        [Fact]
-        public void DecodesIndexedHeaderField_DynamicTable_ReferencedEntryRemovedOnInsertion()
-        {
-            // Pre-populate the dynamic table so we'll have something to reference.
-            // This entry will have index 62 (0x3E).
-            _dynamicTable.Insert(_headerNameBytes, _headerValueBytes);
-            Assert.Equal(1, _dynamicTable.Count);
-
-            Assert.InRange(_dynamicTable.MaxSize, 1, _literalHeaderNameBytes.Length); // Assert that our string will be too big
-
-            byte[] encoded = (new byte[] { 0x40 | 0x3E }) // Indexing enabled (0x40) | dynamic table (62 = 0x3E) as a 6-integer, 
-                .Concat(_literalHeaderName) // A header value that's too large to fit in the dynamic table
-                .ToArray();
-
-            _decoder.Decode(encoded, endHeaders: true, handler: _handler);
-            Assert.Equal(0, _dynamicTable.Count); // The large entry caused the table to be wiped
-            Assert.Equal(_literalHeaderNameString, _handler.DecodedHeaders[_headerNameString]); // but we got the header anyway
-        }
-
         [Fact]
         public void DecodesIndexedHeaderField_OutOfRange_Error()
         {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment