From 709ba4e7b0580b32208384c6cedc9d2bd13da828 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Wed, 9 Oct 2013 21:01:38 -0700 Subject: [PATCH] Semi-fix EOF --- src/ssl/lib.rs | 2 +- src/ssl/test.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/ssl/lib.rs b/src/ssl/lib.rs index 4d79152b..6d08e168 100644 --- a/src/ssl/lib.rs +++ b/src/ssl/lib.rs @@ -225,7 +225,7 @@ impl SslStream { 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(), diff --git a/src/ssl/test.rs b/src/ssl/test.rs index 36969e1b..3432e2a7 100644 --- a/src/ssl/test.rs +++ b/src/ssl/test.rs @@ -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)); +}