Wire in PushPromise

This commit is contained in:
Carl Lerche
2017-08-08 13:32:36 -07:00
parent fa66323cec
commit 314b7a1848
9 changed files with 271 additions and 100 deletions

View File

@@ -58,7 +58,7 @@ enum Inner {
Idle,
// TODO: these states shouldn't count against concurrency limits:
//ReservedLocal,
//ReservedRemote,
ReservedRemote,
Open {
local: Peer,
remote: Peer,
@@ -126,11 +126,16 @@ impl State {
/// Open the receive have of the stream, this action is taken when a HEADERS
/// frame is received.
pub fn recv_open(&mut self, sz: WindowSize, eos: bool) -> Result<(), ConnectionError> {
///
/// Returns true if this transitions the state to Open
pub fn recv_open(&mut self, sz: WindowSize, eos: bool) -> Result<bool, ConnectionError> {
let remote = Peer::streaming(sz);
let mut initial = false;
self.inner = match self.inner {
Idle => {
initial = true;
if eos {
HalfClosedRemote(AwaitingHeaders)
} else {
@@ -140,6 +145,18 @@ impl State {
}
}
}
ReservedRemote => {
initial = true;
if eos {
Closed(None)
} else {
Open {
local: AwaitingHeaders,
remote,
}
}
}
Open { local, remote: AwaitingHeaders } => {
if eos {
HalfClosedRemote(local)
@@ -163,7 +180,18 @@ impl State {
}
};
return Ok(());
return Ok(initial);
}
/// Transition from Idle -> ReservedRemote
pub fn reserve_remote(&mut self) -> Result<(), ConnectionError> {
match self.inner {
Idle => {
self.inner = ReservedRemote;
Ok(())
}
_ => Err(ProtocolError.into()),
}
}
/// Indicates that the remote side will not send more data to the local.