Skip to content

Commit 7b517ea

Browse files
committed
PR feedback
1 parent 34f175b commit 7b517ea

File tree

8 files changed

+17
-17
lines changed

8 files changed

+17
-17
lines changed

src/Servers/Kestrel/Core/src/Internal/Http/Http1MessageBody.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ protected async Task OnConsumeAsyncAwaited()
115115
}
116116
}
117117

118-
protected override void OnOnbservedBytesExceedMaxRequestBodySize(long? maxRequestBodySize)
118+
protected override void OnObservedBytesExceedMaxRequestBodySize(long maxRequestBodySize)
119119
{
120120
_context.DisableKeepAlive(ConnectionEndReason.MaxRequestBodySizeExceeded);
121-
KestrelBadHttpRequestException.Throw(RequestRejectionReason.RequestBodyTooLarge, maxRequestBodySize.GetValueOrDefault().ToString(CultureInfo.InvariantCulture));
121+
KestrelBadHttpRequestException.Throw(RequestRejectionReason.RequestBodyTooLarge, maxRequestBodySize.ToString(CultureInfo.InvariantCulture));
122122
}
123123

124124
public static MessageBody For(

src/Servers/Kestrel/Core/src/Internal/Http/MessageBody.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,13 @@ protected void AddAndCheckObservedBytes(long observedBytes)
191191
var maxRequestBodySize = _context.MaxRequestBodySize;
192192
if (_observedBytes > maxRequestBodySize)
193193
{
194-
OnOnbservedBytesExceedMaxRequestBodySize(maxRequestBodySize);
194+
OnObservedBytesExceedMaxRequestBodySize(maxRequestBodySize.Value);
195195
}
196196
}
197197

198-
protected virtual void OnOnbservedBytesExceedMaxRequestBodySize(long? maxRequestBodySize)
198+
protected virtual void OnObservedBytesExceedMaxRequestBodySize(long maxRequestBodySize)
199199
{
200-
KestrelBadHttpRequestException.Throw(RequestRejectionReason.RequestBodyTooLarge, maxRequestBodySize.GetValueOrDefault().ToString(CultureInfo.InvariantCulture));
200+
KestrelBadHttpRequestException.Throw(RequestRejectionReason.RequestBodyTooLarge, maxRequestBodySize.ToString(CultureInfo.InvariantCulture));
201201
}
202202

203203
protected ValueTask<ReadResult> StartTimingReadAsync(ValueTask<ReadResult> readAwaitable, CancellationToken cancellationToken)

src/Servers/Kestrel/Core/src/Internal/Infrastructure/KestrelMetrics.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ internal static bool TryGetErrorType(ConnectionEndReason reason, [NotNullWhen(tr
497497
ConnectionEndReason.ServerTimeout => "server_timeout",
498498
ConnectionEndReason.StreamCreationError => "stream_creation_error",
499499
ConnectionEndReason.IOError => "io_error",
500-
ConnectionEndReason.AppShutdown => "app_shutdown",
500+
ConnectionEndReason.AppShutdownTimeout => "app_shutdown_timeout",
501501
ConnectionEndReason.TlsHandshakeFailed => "tls_handshake_failed",
502502
ConnectionEndReason.InvalidRequestLine => "invalid_request_line",
503503
ConnectionEndReason.TlsOverHttp => "tls_over_http",

src/Servers/Kestrel/Core/src/Internal/Infrastructure/TransportConnectionManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public async Task<bool> AbortAllConnectionsAsync()
8080
// Connection didn't shutdown in allowed time. Force close the connection and set the end reason.
8181
KestrelMetrics.AddConnectionEndReason(
8282
connection.TransportConnection.Features.Get<IConnectionMetricsContextFeature>()?.MetricsContext,
83-
ConnectionEndReason.AppShutdown, overwrite: true);
83+
ConnectionEndReason.AppShutdownTimeout, overwrite: true);
8484

8585
connection.TransportConnection.Abort(new ConnectionAbortedException(CoreStrings.ConnectionAbortedDuringServerShutdown));
8686
abortTasks.Add(connection.ExecutionTask);

src/Servers/Kestrel/Core/test/Http1/Http1ConnectionTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ static bool TryReadResponse(ReadResult read, out SequencePosition consumed, out
246246
}
247247
Assert.Equal($"{connectionId}:{count:X8}", feature.TraceIdentifier);
248248

249-
_http1Connection.StopProcessingNextRequest(ConnectionEndReason.AppShutdown);
249+
_http1Connection.StopProcessingNextRequest(ConnectionEndReason.AppShutdownTimeout);
250250
await requestProcessingTask.DefaultTimeout();
251251
}
252252

@@ -572,7 +572,7 @@ public async Task ProcessRequestsAsyncEnablesKeepAliveTimeout()
572572
var expectedKeepAliveTimeout = _serviceContext.ServerOptions.Limits.KeepAliveTimeout;
573573
_timeoutControl.Verify(cc => cc.SetTimeout(expectedKeepAliveTimeout, TimeoutReason.KeepAlive));
574574

575-
_http1Connection.StopProcessingNextRequest(ConnectionEndReason.AppShutdown);
575+
_http1Connection.StopProcessingNextRequest(ConnectionEndReason.AppShutdownTimeout);
576576
_application.Output.Complete();
577577

578578
await requestProcessingTask.DefaultTimeout();
@@ -657,7 +657,7 @@ public async Task RequestProcessingTaskIsUnwrapped()
657657
var data = Encoding.ASCII.GetBytes("GET / HTTP/1.1\r\nHost:\r\n\r\n");
658658
await _application.Output.WriteAsync(data);
659659

660-
_http1Connection.StopProcessingNextRequest(ConnectionEndReason.AppShutdown);
660+
_http1Connection.StopProcessingNextRequest(ConnectionEndReason.AppShutdownTimeout);
661661
Assert.IsNotType<Task<Task>>(requestProcessingTask);
662662

663663
await requestProcessingTask.DefaultTimeout();

src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5109,7 +5109,7 @@ public async Task StopProcessingNextRequestSendsGracefulGOAWAYThenFinalGOAWAYWhe
51095109

51105110
await StartStreamAsync(1, _browserRequestHeaders, endStream: false);
51115111

5112-
_connection.StopProcessingNextRequest(ConnectionEndReason.AppShutdown);
5112+
_connection.StopProcessingNextRequest(ConnectionEndReason.AppShutdownTimeout);
51135113
await _closingStateReached.Task.DefaultTimeout();
51145114

51155115
VerifyGoAway(await ReceiveFrameAsync(), Int32.MaxValue, Http2ErrorCode.NO_ERROR);
@@ -5132,7 +5132,7 @@ await ExpectAsync(Http2FrameType.DATA,
51325132
await _closedStateReached.Task.DefaultTimeout();
51335133
VerifyGoAway(await ReceiveFrameAsync(), 1, Http2ErrorCode.NO_ERROR);
51345134

5135-
AssertConnectionEndReason(ConnectionEndReason.AppShutdown);
5135+
AssertConnectionEndReason(ConnectionEndReason.AppShutdownTimeout);
51365136
}
51375137

51385138
[Fact]
@@ -5143,7 +5143,7 @@ public async Task AcceptNewStreamsDuringClosingConnection()
51435143

51445144
await StartStreamAsync(1, _browserRequestHeaders, endStream: false);
51455145

5146-
_connection.StopProcessingNextRequest(ConnectionEndReason.AppShutdown);
5146+
_connection.StopProcessingNextRequest(ConnectionEndReason.AppShutdownTimeout);
51475147
VerifyGoAway(await ReceiveFrameAsync(), Int32.MaxValue, Http2ErrorCode.NO_ERROR);
51485148

51495149
await _closingStateReached.Task.DefaultTimeout();
@@ -5181,7 +5181,7 @@ await ExpectAsync(Http2FrameType.DATA,
51815181

51825182
await WaitForConnectionStopAsync(expectedLastStreamId: 3, ignoreNonGoAwayFrames: false);
51835183

5184-
AssertConnectionEndReason(ConnectionEndReason.AppShutdown);
5184+
AssertConnectionEndReason(ConnectionEndReason.AppShutdownTimeout);
51855185
}
51865186

51875187
[Fact]

src/Servers/Kestrel/test/InMemory.FunctionalTests/KestrelMetricsTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public async Task Http1Connection_ServerShutdown_Abort()
305305

306306
Assert.Collection(connectionDuration.GetMeasurementSnapshot(), m =>
307307
{
308-
AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", KestrelMetrics.Http11, error: KestrelMetrics.GetErrorType(ConnectionEndReason.AppShutdown));
308+
AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", KestrelMetrics.Http11, error: KestrelMetrics.GetErrorType(ConnectionEndReason.AppShutdownTimeout));
309309
});
310310
}
311311

@@ -647,7 +647,7 @@ public async Task Http2Connection_ServerShutdown_Abort()
647647
await shutdownTask;
648648
}
649649

650-
Assert.Collection(connectionDuration.GetMeasurementSnapshot(), m => AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", KestrelMetrics.Http2, error: KestrelMetrics.GetErrorType(ConnectionEndReason.AppShutdown)));
650+
Assert.Collection(connectionDuration.GetMeasurementSnapshot(), m => AssertDuration(m, "127.0.0.1", localPort: 0, "tcp", "ipv4", KestrelMetrics.Http2, error: KestrelMetrics.GetErrorType(ConnectionEndReason.AppShutdownTimeout)));
651651
}
652652

653653
[ConditionalFact]

src/Shared/ServerInfrastructure/Http2/ConnectionEndReason.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ internal enum ConnectionEndReason
4343
StreamCreationError,
4444
IOError,
4545
ClientGoAway,
46-
AppShutdown,
46+
AppShutdownTimeout,
4747
GracefulAppShutdown,
4848
TransportCompleted,
4949
TlsHandshakeFailed,

0 commit comments

Comments
 (0)