Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read/Write impl rework for rustls #592

Merged
merged 4 commits into from Jul 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 14 additions & 5 deletions src/download/src/lib.rs
Expand Up @@ -366,6 +366,7 @@ pub mod rustls {
use hyper_base;
use self::hyper::error::Result as HyperResult;
use self::hyper::net::{SslClient, NetworkStream};
use self::rustls::Session;
use std::io::Result as IoResult;
use std::io::{Read, Write};
use std::net::{SocketAddr, Shutdown};
Expand Down Expand Up @@ -491,8 +492,18 @@ pub mod rustls {
.and_then(|mut t| {
let (ref mut stream, ref mut tls) = *t;
while tls.wants_read() {
tls.read_tls(stream).unwrap(); // FIXME
tls.process_new_packets().unwrap(); // FIXME
match tls.read_tls(stream) {
Ok(_) => {
match tls.process_new_packets() {
Ok(_) => (),
Err(e) => return Err(io::Error::new(io::ErrorKind::Other, format!("{:?}", e)))
}
while tls.wants_write() {
try!(tls.write_tls(stream));
}
},
Err(e) => return Err(e),
}
}

tls.read(buf)
Expand All @@ -507,11 +518,9 @@ pub mod rustls {
self.lock()
.and_then(|mut t| {
let (ref mut stream, ref mut tls) = *t;

let res = tls.write(buf);

while tls.wants_write() {
tls.write_tls(stream).unwrap(); // FIXME
try!(tls.write_tls(stream));
}

res
Expand Down