This repository was archived by the owner on Dec 18, 2018. It is now read-only.
File tree 3 files changed +31
-1
lines changed
src/Microsoft.AspNetCore.Server.Kestrel/Internal/Http
test/Microsoft.AspNetCore.Server.KestrelTests
tools/Microsoft.AspNetCore.Server.Kestrel.GeneratedCode
3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -3404,6 +3404,7 @@ protected override bool RemoveFast(string key)
3404
3404
{
3405
3405
if ( ( ( _bits & 2048L ) != 0 ) )
3406
3406
{
3407
+ _contentLength = null ;
3407
3408
_bits &= ~ 2048L ;
3408
3409
_headers . _ContentLength = StringValues . Empty ;
3409
3410
return true ;
@@ -3700,6 +3701,7 @@ protected override void ClearFast()
3700
3701
{
3701
3702
_bits = 0 ;
3702
3703
_headers = default ( HeaderReferences ) ;
3704
+ _contentLength = null ;
3703
3705
MaybeUnknown ? . Clear ( ) ;
3704
3706
}
3705
3707
@@ -8358,6 +8360,7 @@ protected override bool RemoveFast(string key)
8358
8360
{
8359
8361
if ( ( ( _bits & 2048L ) != 0 ) )
8360
8362
{
8363
+ _contentLength = null ;
8361
8364
_bits &= ~ 2048L ;
8362
8365
_headers . _ContentLength = StringValues . Empty ;
8363
8366
_headers . _rawContentLength = null ;
@@ -8609,6 +8612,7 @@ protected override void ClearFast()
8609
8612
{
8610
8613
_bits = 0 ;
8611
8614
_headers = default ( HeaderReferences ) ;
8615
+ _contentLength = null ;
8612
8616
MaybeUnknown ? . Clear ( ) ;
8613
8617
}
8614
8618
Original file line number Diff line number Diff line change @@ -201,5 +201,29 @@ public void ContentLengthValueCanBeReadAsLongAfterAssigningHeader()
201
201
202
202
Assert . Equal ( 42 , headers . HeaderContentLengthValue ) ;
203
203
}
204
+
205
+ [ Fact ]
206
+ public void ContentLengthValueClearedWhenHeaderIsRemoved ( )
207
+ {
208
+ var headers = new FrameResponseHeaders ( ) ;
209
+ headers . HeaderContentLength = "42" ;
210
+ var dictionary = ( IDictionary < string , StringValues > ) headers ;
211
+
212
+ dictionary . Remove ( "Content-Length" ) ;
213
+
214
+ Assert . Equal ( null , headers . HeaderContentLengthValue ) ;
215
+ }
216
+
217
+ [ Fact ]
218
+ public void ContentLengthValueClearedWhenHeadersCleared ( )
219
+ {
220
+ var headers = new FrameResponseHeaders ( ) ;
221
+ headers . HeaderContentLength = "42" ;
222
+ var dictionary = ( IDictionary < string , StringValues > ) headers ;
223
+
224
+ dictionary . Clear ( ) ;
225
+
226
+ Assert . Equal ( null , headers . HeaderContentLengthValue ) ;
227
+ }
204
228
}
205
229
}
Original file line number Diff line number Diff line change @@ -361,7 +361,8 @@ protected override bool RemoveFast(string key)
361
361
if ( "" { header . Name } "" . Equals ( key , StringComparison . OrdinalIgnoreCase ) )
362
362
{ {
363
363
if ( { header . TestBit ( ) } )
364
- { {
364
+ { { { If ( header . Identifier == "ContentLength" , ( ) => $@ "
365
+ _contentLength = null;" ) }
365
366
{ header. ClearBit ( ) } ;
366
367
_headers . _ { header . Identifier } = StringValues . Empty ; { ( header . EnhancedSetter == false ? "" : $@ "
367
368
_headers._raw{ header . Identifier } = null;" ) }
@@ -381,6 +382,7 @@ protected override void ClearFast()
381
382
{ {
382
383
_bits = 0 ;
383
384
_headers = default ( HeaderReferences ) ;
385
+ _contentLength = null ;
384
386
MaybeUnknown ? . Clear ( ) ;
385
387
} }
386
388
You can’t perform that action at this time.
0 commit comments