1
0
Fork 0
mirror of https://github.com/VSadov/Satori.git synced 2025-06-11 18:20:26 +09:00

Sync shared code from aspnetcore (#105765)

Co-authored-by: Tratcher <Tratcher@users.noreply.github.com>
Co-authored-by: Andrew Casey <amcasey@users.noreply.github.com>
Co-authored-by: Larry Ewing <lewing@microsoft.com>
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
This commit is contained in:
github-actions[bot] 2024-08-02 10:49:24 -07:00 committed by GitHub
parent 3e572e9d09
commit d9fc0f14a5
Signed by: github
GPG key ID: B5690EEEBB952194

View file

@ -87,6 +87,10 @@ 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 };
@ -243,6 +247,43 @@ 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()
{
@ -254,6 +295,19 @@ 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()
{
@ -265,6 +319,17 @@ 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()
{
@ -276,6 +341,19 @@ 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()
{