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:
George Barnett authored and Cory Benfield committed 2019-03-15 12:40:50 +00:00
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