mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-26 04:57:50 +00:00
Ensure preamble only gets sent once. (#61)
Motivation: In certain cases it was possible for preamble to be sent once; this would lead to frames getting sent more than once which in turn would break state machines. Modifications: - Check the state of the connection before sending preamble. - Include a test to check. Result: More correct implementation
This commit is contained in:
1 parent
ddf2c29493
commit
348a10ee19
4 files changed
+48
No files matched your search
@@ -460,6 +460,16 @@ struct HTTP2ConnectionStateMachine {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether the preamble can be sent.
|
||||
var mustSendPreamble: Bool {
|
||||
switch self.state {
|
||||
case .idle, .prefaceReceived, .quiescingPrefaceReceived:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK:- State modifying methods
|
||||
|
||||
Reference in new issue
Block a user