in Sources/NIOHTTP2/ConnectionStateMachine/ConnectionStateMachine.swift [909:966]
mutating func receiveRstStream(streamID: HTTP2StreamID, reason: HTTP2ErrorCode) -> StateMachineResultWithEffect {
switch self.state {
case .prefaceReceived(var state):
return self.avoidingStateMachineCoW { newState in
let result = state.receiveRstStream(streamID: streamID, reason: reason)
newState = .prefaceReceived(state)
return result
}
case .active(var state):
return self.avoidingStateMachineCoW { newState in
let result = state.receiveRstStream(streamID: streamID, reason: reason)
newState = .active(state)
return result
}
case .locallyQuiesced(var state):
return self.avoidingStateMachineCoW { newState in
let result = state.receiveRstStream(streamID: streamID, reason: reason)
newState = .locallyQuiesced(state)
newState.closeIfNeeded(state)
return result
}
case .remotelyQuiesced(var state):
return self.avoidingStateMachineCoW { newState in
let result = state.receiveRstStream(streamID: streamID, reason: reason)
newState = .remotelyQuiesced(state)
newState.closeIfNeeded(state)
return result
}
case .bothQuiescing(var state):
return self.avoidingStateMachineCoW { newState in
let result = state.receiveRstStream(streamID: streamID, reason: reason)
newState = .bothQuiescing(state)
newState.closeIfNeeded(state)
return result
}
case .quiescingPrefaceReceived(var state):
return self.avoidingStateMachineCoW { newState in
let result = state.receiveRstStream(streamID: streamID, reason: reason)
newState = .quiescingPrefaceReceived(state)
return result
}
case .idle, .prefaceSent, .quiescingPrefaceSent:
// We're waiting for the remote preface.
return .init(result: .connectionError(underlyingError: NIOHTTP2Errors.missingPreface(), type: .protocolError), effect: nil)
case .fullyQuiesced:
return .init(result: .connectionError(underlyingError: NIOHTTP2Errors.ioOnClosedConnection(), type: .protocolError), effect: nil)
case .modifying:
preconditionFailure("Must not be left in modifying state")
}
}