private void CheckForTimeout(long timestamp) { // TODO: Use PlatformApis.VolatileRead equivalent again if (timestamp > Interlocked.Read(ref _timeoutTimestamp)) { if (!Debugger.IsAttached) { CancelTimeout(); switch (_timeoutAction) { case TimeoutAction.StopProcessingNextRequest: // Http/2 keep-alive timeouts are not yet supported. _http1Connection?.StopProcessingNextRequest(); break; case TimeoutAction.SendTimeoutResponse: // HTTP/2 timeout responses are not yet supported. if (_http1Connection != null) { RequestTimedOut = true; _http1Connection.SendTimeoutResponse(); } break; case TimeoutAction.AbortConnection: // This is actually supported with HTTP/2! Abort(new TimeoutException()); break; } } } }
public void OnTimeout(TimeoutReason reason) { // In the cases that don't log directly here, we expect the setter of the timeout to also be the input // reader, so when the read is canceled or aborted, the reader should write the appropriate log. switch (reason) { case TimeoutReason.KeepAlive: _http1Connection.StopProcessingNextRequest(); break; case TimeoutReason.RequestHeaders: _http1Connection.SendTimeoutResponse(); break; case TimeoutReason.ReadDataRate: Log.RequestBodyMinimumDataRateNotSatisfied(_context.ConnectionId, _http1Connection.TraceIdentifier, _http1Connection.MinRequestBodyDataRate.BytesPerSecond); _http1Connection.SendTimeoutResponse(); break; case TimeoutReason.WriteDataRate: Log.ResponseMinimumDataRateNotSatisfied(_http1Connection.ConnectionIdFeature, _http1Connection.TraceIdentifier); Abort(new ConnectionAbortedException(CoreStrings.ConnectionTimedBecauseResponseMininumDataRateNotSatisfied)); break; case TimeoutReason.RequestBodyDrain: case TimeoutReason.TimeoutFeature: Abort(new ConnectionAbortedException(CoreStrings.ConnectionTimedOutByServer)); break; default: Debug.Assert(false, "Invalid TimeoutReason"); break; } }
public void SendTimeoutResponse() { Debug.Assert(_http1Connection != null, $"{nameof(_http1Connection)} is null"); Debug.Assert(_http2Connection != null, $"{nameof(_http2Connection)} is null"); RequestTimedOut = true; _http1Connection.SendTimeoutResponse(); }