-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bug where client ignores HEADERS frames on open stream when locally quiescing #445
Conversation
…m when locally quiescing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, I only style/naming comments.
Sources/NIOHTTP2/ConnectionStateMachine/FrameReceivingStates/ReceivingHeadersState.swift
Outdated
Show resolved
Hide resolved
extension HTTP2ConnectionStateMachine.ConnectionRole { | ||
/// Obtain the inverse role to self | ||
/// - Returns: The inverse role | ||
fileprivate func inverse() -> Self { | ||
switch self { | ||
case .server: | ||
return .client | ||
case .client: | ||
return .server | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we move this to where ConnectionRole
is defined?
@swift-server-bot add to allowlist |
Sources/NIOHTTP2/ConnectionStateMachine/ConnectionStateMachine.swift
Outdated
Show resolved
Hide resolved
Sources/NIOHTTP2/ConnectionStateMachine/LocallyQuiescingState.swift
Outdated
Show resolved
Hide resolved
@@ -17,7 +17,7 @@ import NIOHPACK | |||
/// can validly accept headers. | |||
/// | |||
/// This protocol should only be conformed to by states for the HTTP/2 connection state machine. | |||
protocol ReceivingHeadersState: HasFlowControlWindows, HasLocalExtendedConnectSettings, HasRemoteExtendedConnectSettings { | |||
protocol ReceivingHeadersState: HasFlowControlWindows, HasLocalExtendedConnectSettings, HasRemoteExtendedConnectSettings, ConnectionStateWithRole { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the protocol constraint here at all? We already have the role
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, I'm happy if George is happy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks @aryan-25!
Motivation:
Currently, HEADERS frames are ignored by the client on a client-initiated stream after the client sends a GOAWAY.
As per Section 6.8 (GOAWAY) in RFC 9113:
"Once the GOAWAY is sent, the sender will ignore frames sent on streams initiated by the receiver if the stream has an identifier higher than the included last stream identifier."
In this case, the client (sender) should not ignore the HEADERS frame as the stream is initiated by the client, not the receiver.
Modifications:
Fixed the condition in the
receiveHeaders
function (givenLocallyQuiescingState
) inReceivingHeadersState.swift
to work for both the client and server roles -- before this change, the condition is only correct whenself.role == ConnectionRole.server
.Result:
HEADERS frames are not ignored by the client on a client-initiated stream when locally quiescing.