mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-28 05:14:25 +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
@@ -318,6 +318,10 @@ extension NIOHTTP2Handler {
|
||||
extension NIOHTTP2Handler {
|
||||
/// Issues the preamble when necessary.
|
||||
private func writeAndFlushPreamble(context: ChannelHandlerContext) {
|
||||
guard self.stateMachine.mustSendPreamble else {
|
||||
return
|
||||
}
|
||||
|
||||
if case .client = self.mode {
|
||||
self.writeBuffer.clear()
|
||||
self.writeBuffer.writeStaticString(NIOHTTP2Handler.clientMagic)
|
||||
|
||||
Reference in new issue
Block a user