mutating func receiveData()

in Sources/NIOHTTP2/ConnectionStateMachine/ConnectionStateMachine.swift [751:808]


    mutating func receiveData(streamID: HTTP2StreamID, contentLength: Int, flowControlledBytes: Int, isEndStreamSet endStream: Bool) -> StateMachineResultWithEffect {
        switch self.state {
        case .prefaceReceived(var state):
            return self.avoidingStateMachineCoW { newState in
                let result = state.receiveData(streamID: streamID, contentLength: contentLength, flowControlledBytes: flowControlledBytes, isEndStreamSet: endStream)
                newState = .prefaceReceived(state)
                return result
            }

        case .active(var state):
            return self.avoidingStateMachineCoW { newState in
                let result = state.receiveData(streamID: streamID, contentLength: contentLength, flowControlledBytes: flowControlledBytes, isEndStreamSet: endStream)
                newState = .active(state)
                return result
            }

        case .locallyQuiesced(var state):
            return self.avoidingStateMachineCoW { newState in
                let result = state.receiveData(streamID: streamID, contentLength: contentLength, flowControlledBytes: flowControlledBytes, isEndStreamSet: endStream)
                newState = .locallyQuiesced(state)
                newState.closeIfNeeded(state)
                return result
            }

        case .remotelyQuiesced(var state):
            return self.avoidingStateMachineCoW { newState in
                let result = state.receiveData(streamID: streamID, contentLength: contentLength, flowControlledBytes: flowControlledBytes, isEndStreamSet: endStream)
                newState = .remotelyQuiesced(state)
                newState.closeIfNeeded(state)
                return result
            }

        case .bothQuiescing(var state):
            return self.avoidingStateMachineCoW { newState in
                let result = state.receiveData(streamID: streamID, contentLength: contentLength, flowControlledBytes: flowControlledBytes, isEndStreamSet: endStream)
                newState = .bothQuiescing(state)
                newState.closeIfNeeded(state)
                return result
            }

        case .quiescingPrefaceReceived(var state):
            return self.avoidingStateMachineCoW { newState in
                let result = state.receiveData(streamID: streamID, contentLength: contentLength, flowControlledBytes: flowControlledBytes, isEndStreamSet: endStream)
                newState = .quiescingPrefaceReceived(state)
                return result
            }

        case .idle, .prefaceSent, .quiescingPrefaceSent:
            // If we're still waiting for the remote preface, we are not allowed to receive a DATA frame yet!
            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")
        }
    }