/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
*/ package org.apache.coyote.http2;
/** * See <a href="https://tools.ietf.org/html/rfc7540#section-5.1">state diagram</a> in RFC 7540. <br> * The following additions are supported by this state machine: * <ul> * <li>differentiate between closed (normal) and closed caused by reset</li> * </ul>
*/ class StreamStateMachine {
privatestaticfinal Log log = LogFactory.getLog(StreamStateMachine.class); privatestaticfinal StringManager sm = StringManager.getManager(StreamStateMachine.class);
/** * Marks the stream as reset. This method will not change the stream state if: * <ul> * <li>The stream is already reset</li> * <li>The stream is already closed</li> * </ul> * * @throws IllegalStateException If the stream is in a state that does not permit resets
*/ publicsynchronizedvoid sendReset() { if (state == State.IDLE) { thrownew IllegalStateException(
sm.getString("streamStateMachine.debug.change", connectionId, streamId, state));
} if (state.canReset()) {
stateChange(state, State.CLOSED_RST_TX);
}
}
privatevoid stateChange(State oldState, State newState) { if (state == oldState) {
state = newState; if (log.isDebugEnabled()) {
log.debug(sm.getString("streamStateMachine.debug.change", connectionId, streamId, oldState, newState));
}
}
}
finalsynchronizedvoid checkFrameType(FrameType frameType) throws Http2Exception { // No state change. Checks that receiving the frame type is valid for // the current state of this stream. if (!isFrameTypePermitted(frameType)) { if (state.connectionErrorForInvalidFrame) { thrownew ConnectionException(
sm.getString("streamStateMachine.invalidFrame", connectionId, streamId, state, frameType),
state.errorCodeForInvalidFrame);
} else { thrownew StreamException(
sm.getString("streamStateMachine.invalidFrame", connectionId, streamId, state, frameType),
state.errorCodeForInvalidFrame, Integer.parseInt(streamId));
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.