File tree Expand file tree Collapse file tree 6 files changed +16
-31
lines changed
src/Servers/Kestrel/Core/src/Internal Expand file tree Collapse file tree 6 files changed +16
-31
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,8 @@ internal abstract class Http1MessageBody : MessageBody
16
16
protected readonly Http1Connection _context ;
17
17
protected bool _completed ;
18
18
19
- protected Http1MessageBody ( Http1Connection context )
19
+ protected Http1MessageBody ( Http1Connection context ) : base ( context )
20
20
{
21
- Reset ( context ) ;
22
21
_context = context ;
23
22
}
24
23
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ internal abstract class MessageBody
15
15
private static readonly MessageBody _zeroContentLengthClose = new ZeroContentLengthMessageBody ( keepAlive : false ) ;
16
16
private static readonly MessageBody _zeroContentLengthKeepAlive = new ZeroContentLengthMessageBody ( keepAlive : true ) ;
17
17
18
- private HttpProtocol _context ;
18
+ private readonly HttpProtocol _context ;
19
19
20
20
private bool _send100Continue = true ;
21
21
private long _consumedBytes ;
@@ -26,6 +26,11 @@ internal abstract class MessageBody
26
26
protected long _alreadyTimedBytes ;
27
27
protected long _examinedUnconsumedBytes ;
28
28
29
+ protected MessageBody ( HttpProtocol context )
30
+ {
31
+ _context = context ;
32
+ }
33
+
29
34
public static MessageBody ZeroContentLengthClose => _zeroContentLengthClose ;
30
35
31
36
public static MessageBody ZeroContentLengthKeepAlive => _zeroContentLengthKeepAlive ;
@@ -68,9 +73,8 @@ public virtual Task StopAsync()
68
73
69
74
protected virtual Task OnStopAsync ( ) => Task . CompletedTask ;
70
75
71
- protected void Reset ( HttpProtocol context )
76
+ protected void Reset ( )
72
77
{
73
- _context = context ;
74
78
_send100Continue = true ;
75
79
_consumedBytes = 0 ;
76
80
_stopped = false ;
Original file line number Diff line number Diff line change @@ -11,8 +11,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
11
11
internal sealed class ZeroContentLengthMessageBody : MessageBody
12
12
{
13
13
public ZeroContentLengthMessageBody ( bool keepAlive )
14
+ : base ( null )
14
15
{
15
- Reset ( null ) ;
16
16
RequestKeepAlive = keepAlive ;
17
17
}
18
18
Original file line number Diff line number Diff line change @@ -12,12 +12,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2
12
12
{
13
13
internal sealed class Http2MessageBody : MessageBody
14
14
{
15
- private Http2Stream _context ;
15
+ private readonly Http2Stream _context ;
16
16
private ReadResult _readResult ;
17
17
18
- public Http2MessageBody ( Http2Stream context )
18
+ public Http2MessageBody ( Http2Stream context ) : base ( context )
19
19
{
20
- Reset ( context ) ;
20
+ _context = context ;
21
21
}
22
22
23
23
protected override void OnReadStarting ( )
@@ -45,26 +45,9 @@ protected override void OnDataRead(long bytesRead)
45
45
AddAndCheckConsumedBytes ( bytesRead ) ;
46
46
}
47
47
48
- public static MessageBody For ( Http2Stream context , Http2MessageBody previousMessageBody )
48
+ public new void Reset ( )
49
49
{
50
- if ( context . ReceivedEmptyRequestBody )
51
- {
52
- return ZeroContentLengthClose ;
53
- }
54
-
55
- if ( previousMessageBody is Http2MessageBody http2MessageBody )
56
- {
57
- http2MessageBody . Reset ( context ) ;
58
- return http2MessageBody ;
59
- }
60
-
61
- return new Http2MessageBody ( context ) ;
62
- }
63
-
64
- public void Reset ( Http2Stream context )
65
- {
66
- base . Reset ( context ) ;
67
- _context = context ;
50
+ base . Reset ( ) ;
68
51
_readResult = default ;
69
52
}
70
53
Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ protected override MessageBody CreateMessageBody()
179
179
180
180
if ( _messageBody != null )
181
181
{
182
- _messageBody . Reset ( this ) ;
182
+ _messageBody . Reset ( ) ;
183
183
}
184
184
else
185
185
{
Original file line number Diff line number Diff line change @@ -15,9 +15,8 @@ internal sealed class Http3MessageBody : MessageBody
15
15
private readonly Http3Stream _context ;
16
16
private ReadResult _readResult ;
17
17
18
- private Http3MessageBody ( Http3Stream context )
18
+ private Http3MessageBody ( Http3Stream context ) : base ( context )
19
19
{
20
- Reset ( context ) ;
21
20
_context = context ;
22
21
}
23
22
protected override void OnReadStarting ( )
You can’t perform that action at this time.
0 commit comments