fix early-data read
This commit is contained in:
parent
ee59a7cc8e
commit
d8ab52db55
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "tokio-rustls"
|
name = "tokio-rustls"
|
||||||
version = "0.10.0-alpha"
|
version = "0.10.0-alpha.1"
|
||||||
authors = ["quininer kel <quininer@live.com>"]
|
authors = ["quininer kel <quininer@live.com>"]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
repository = "https://github.com/quininer/tokio-rustls"
|
repository = "https://github.com/quininer/tokio-rustls"
|
||||||
|
@ -79,13 +79,13 @@ impl<IO> io::Read for TlsStream<IO>
|
|||||||
where IO: AsyncRead + AsyncWrite
|
where IO: AsyncRead + AsyncWrite
|
||||||
{
|
{
|
||||||
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
|
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
|
||||||
let mut stream = Stream::new(&mut self.io, &mut self.session);
|
|
||||||
|
|
||||||
match self.state {
|
match self.state {
|
||||||
#[cfg(feature = "early-data")]
|
#[cfg(feature = "early-data")]
|
||||||
TlsState::EarlyData => {
|
TlsState::EarlyData => {
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
|
{
|
||||||
|
let mut stream = Stream::new(&mut self.io, &mut self.session);
|
||||||
let (pos, data) = &mut self.early_data;
|
let (pos, data) = &mut self.early_data;
|
||||||
|
|
||||||
// complete handshake
|
// complete handshake
|
||||||
@ -104,9 +104,14 @@ where IO: AsyncRead + AsyncWrite
|
|||||||
// end
|
// end
|
||||||
self.state = TlsState::Stream;
|
self.state = TlsState::Stream;
|
||||||
data.clear();
|
data.clear();
|
||||||
stream.read(buf)
|
}
|
||||||
|
|
||||||
|
self.read(buf)
|
||||||
},
|
},
|
||||||
TlsState::Stream => match stream.read(buf) {
|
TlsState::Stream => {
|
||||||
|
let mut stream = Stream::new(&mut self.io, &mut self.session);
|
||||||
|
|
||||||
|
match stream.read(buf) {
|
||||||
Ok(0) => {
|
Ok(0) => {
|
||||||
self.state = TlsState::Eof;
|
self.state = TlsState::Eof;
|
||||||
Ok(0)
|
Ok(0)
|
||||||
@ -118,6 +123,7 @@ where IO: AsyncRead + AsyncWrite
|
|||||||
Ok(0)
|
Ok(0)
|
||||||
},
|
},
|
||||||
Err(e) => Err(e)
|
Err(e) => Err(e)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
TlsState::Eof | TlsState::Shutdown => Ok(0),
|
TlsState::Eof | TlsState::Shutdown => Ok(0),
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user