@@ -87,6 +87,10 @@ public class HPackDecoderTests
87
87
. Concat ( _headerValueHuffmanBytes )
88
88
. ToArray ( ) ;
89
89
90
+ private static readonly byte [ ] _literalEmptyString = new byte [ ] { 0x00 } ;
91
+
92
+ private static readonly byte [ ] _literalEmptyStringHuffman = new byte [ ] { 0x80 } ;
93
+
90
94
// & *
91
95
// 11111000 11111111
92
96
private static readonly byte [ ] _huffmanLongPadding = new byte [ ] { 0x82 , 0xf8 , 0xff } ;
@@ -243,6 +247,43 @@ public void DecodesLiteralHeaderFieldWithoutIndexing_NewName()
243
247
TestDecodeWithoutIndexing ( encoded , _headerNameString , _headerValueString ) ;
244
248
}
245
249
250
+ [ Fact ]
251
+ public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_EmptyName ( )
252
+ {
253
+ byte [ ] encoded = _literalHeaderFieldWithoutIndexingNewName
254
+ . Concat ( _literalEmptyString )
255
+ . Concat ( _headerValue )
256
+ . ToArray ( ) ;
257
+
258
+ HPackDecodingException exception = Assert . Throws < HPackDecodingException > ( ( ) => _decoder . Decode ( encoded , endHeaders : true , handler : _handler ) ) ;
259
+ Assert . Equal ( SR . Format ( SR . net_http_invalid_header_name , string . Empty ) , exception . Message ) ;
260
+ Assert . Empty ( _handler . DecodedHeaders ) ;
261
+ }
262
+
263
+ [ Fact ]
264
+ public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_EmptyValue ( )
265
+ {
266
+ byte [ ] encoded = _literalHeaderFieldWithoutIndexingNewName
267
+ . Concat ( _headerName )
268
+ . Concat ( _literalEmptyString )
269
+ . ToArray ( ) ;
270
+
271
+ TestDecodeWithoutIndexing ( encoded , _headerNameString , string . Empty ) ;
272
+ }
273
+
274
+ [ Fact ]
275
+ public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_EmptyNameAndValue ( )
276
+ {
277
+ byte [ ] encoded = _literalHeaderFieldWithoutIndexingNewName
278
+ . Concat ( _literalEmptyString )
279
+ . Concat ( _literalEmptyString )
280
+ . ToArray ( ) ;
281
+
282
+ HPackDecodingException exception = Assert . Throws < HPackDecodingException > ( ( ) => _decoder . Decode ( encoded , endHeaders : true , handler : _handler ) ) ;
283
+ Assert . Equal ( SR . Format ( SR . net_http_invalid_header_name , string . Empty ) , exception . Message ) ;
284
+ Assert . Empty ( _handler . DecodedHeaders ) ;
285
+ }
286
+
246
287
[ Fact ]
247
288
public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedName ( )
248
289
{
@@ -254,6 +295,19 @@ public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedName(
254
295
TestDecodeWithoutIndexing ( encoded , _headerNameString , _headerValueString ) ;
255
296
}
256
297
298
+ [ Fact ]
299
+ public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedName_Empty ( )
300
+ {
301
+ byte [ ] encoded = _literalHeaderFieldWithoutIndexingNewName
302
+ . Concat ( _literalEmptyStringHuffman )
303
+ . Concat ( _headerValue )
304
+ . ToArray ( ) ;
305
+
306
+ HPackDecodingException exception = Assert . Throws < HPackDecodingException > ( ( ) => _decoder . Decode ( encoded , endHeaders : true , handler : _handler ) ) ;
307
+ Assert . Equal ( SR . Format ( SR . net_http_invalid_header_name , string . Empty ) , exception . Message ) ;
308
+ Assert . Empty ( _handler . DecodedHeaders ) ;
309
+ }
310
+
257
311
[ Fact ]
258
312
public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedValue ( )
259
313
{
@@ -265,6 +319,17 @@ public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedValue
265
319
TestDecodeWithoutIndexing ( encoded , _headerNameString , _headerValueString ) ;
266
320
}
267
321
322
+ [ Fact ]
323
+ public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedValue_Empty ( )
324
+ {
325
+ byte [ ] encoded = _literalHeaderFieldWithoutIndexingNewName
326
+ . Concat ( _headerName )
327
+ . Concat ( _literalEmptyStringHuffman )
328
+ . ToArray ( ) ;
329
+
330
+ TestDecodeWithoutIndexing ( encoded , _headerNameString , string . Empty ) ;
331
+ }
332
+
268
333
[ Fact ]
269
334
public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedNameAndValue ( )
270
335
{
@@ -276,6 +341,19 @@ public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedNameA
276
341
TestDecodeWithoutIndexing ( encoded , _headerNameString , _headerValueString ) ;
277
342
}
278
343
344
+ [ Fact ]
345
+ public void DecodesLiteralHeaderFieldWithoutIndexing_NewName_HuffmanEncodedNameAndValue_Empty ( )
346
+ {
347
+ byte [ ] encoded = _literalHeaderFieldWithoutIndexingNewName
348
+ . Concat ( _literalEmptyStringHuffman )
349
+ . Concat ( _literalEmptyStringHuffman )
350
+ . ToArray ( ) ;
351
+
352
+ HPackDecodingException exception = Assert . Throws < HPackDecodingException > ( ( ) => _decoder . Decode ( encoded , endHeaders : true , handler : _handler ) ) ;
353
+ Assert . Equal ( SR . Format ( SR . net_http_invalid_header_name , string . Empty ) , exception . Message ) ;
354
+ Assert . Empty ( _handler . DecodedHeaders ) ;
355
+ }
356
+
279
357
[ Fact ]
280
358
public void DecodesLiteralHeaderFieldWithoutIndexing_IndexedName ( )
281
359
{
0 commit comments