Semi-fix EOF

This commit is contained in:
Steven Fackler 2013-10-09 21:01:38 -07:00
parent e2be42aa53
commit 709ba4e7b0
2 changed files with 13 additions and 1 deletions

View File

@ -225,7 +225,7 @@ impl<S: Stream> SslStream<S> {
self.flush();
match self.stream.read(self.buf) {
Some(len) => self.rbio.write(self.buf.slice_to(len)),
None => unreachable!() // FIXME
None => return Err(ErrorZeroReturn) // FIXME
}
}
ErrorWantWrite => self.flush(),

View File

@ -1,8 +1,10 @@
extern mod ssl;
use std::rt::io::{Writer, Reader};
use std::rt::io::extensions::{ReaderUtil};
use std::rt::io::net::tcp::TcpStream;
use std::vec;
use std::str;
use ssl::{Sslv23, SslCtx, SslStream};
@ -27,3 +29,13 @@ fn test_write() {
stream.flush();
stream.shutdown();
}
#[test]
fn test_read() {
let stream = TcpStream::connect(FromStr::from_str("127.0.0.1:15418").unwrap()).unwrap();
let mut stream = SslStream::new(SslCtx::new(Sslv23), stream);
stream.write("GET /\r\n\r\n".as_bytes());
stream.flush();
let buf = stream.read_to_end();
print!("{}", str::from_utf8(buf));
}