Fix 0-RTT fallback
This commit is contained in:
parent
ff3d0a4de3
commit
ba909ed95e
@ -167,15 +167,27 @@ where
|
||||
.set_eof(!this.state.readable());
|
||||
|
||||
#[cfg(feature = "early-data")] {
|
||||
if let TlsState::EarlyData = this.state {
|
||||
let (pos, data) = &mut this.early_data;
|
||||
|
||||
// complete handshake
|
||||
while stream.session.is_handshaking() {
|
||||
futures::ready!(stream.handshake(cx))?;
|
||||
}
|
||||
|
||||
// write early data (fallback)
|
||||
if !stream.session.is_early_data_accepted() {
|
||||
while *pos < data.len() {
|
||||
let len = futures::ready!(stream.as_mut_pin().poll_write(cx, &data[*pos..]))?;
|
||||
*pos += len;
|
||||
}
|
||||
}
|
||||
|
||||
this.state = TlsState::Stream;
|
||||
let (_, data) = &mut this.early_data;
|
||||
*data = Vec::new();
|
||||
}
|
||||
}
|
||||
|
||||
stream.as_mut_pin().poll_flush(cx)
|
||||
}
|
||||
@ -186,14 +198,16 @@ where
|
||||
self.state.shutdown_write();
|
||||
}
|
||||
|
||||
#[cfg(feature = "early-data")] {
|
||||
// we skip the handshake
|
||||
if let TlsState::EarlyData = self.state {
|
||||
return Pin::new(&mut self.io).poll_shutdown(cx);
|
||||
}
|
||||
}
|
||||
|
||||
let this = self.get_mut();
|
||||
let mut stream = Stream::new(&mut this.io, &mut this.session)
|
||||
.set_eof(!this.state.readable());
|
||||
|
||||
// TODO
|
||||
//
|
||||
// should we complete the handshake?
|
||||
|
||||
stream.as_mut_pin().poll_shutdown(cx)
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,6 @@ impl<'a, IO: AsyncRead + AsyncWrite + Unpin, S: Session> AsyncWrite for Stream<'
|
||||
while self.session.wants_write() {
|
||||
futures::ready!(self.write_io(cx))?;
|
||||
}
|
||||
|
||||
Pin::new(&mut self.io).poll_shutdown(cx)
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ impl TlsConnector {
|
||||
|
||||
#[cfg(feature = "early-data")]
|
||||
{
|
||||
Connect(if self.early_data {
|
||||
Connect(if self.early_data && session.early_data().is_some() {
|
||||
client::MidHandshake::EarlyData(client::TlsStream {
|
||||
session,
|
||||
io: stream,
|
||||
|
Loading…
Reference in New Issue
Block a user