Use unboxed WrappedStream.

This commit is contained in:
Sergio Benitez 2017-04-22 22:17:21 -07:00
parent 0a8de2f0a6
commit 45eb475607
2 changed files with 6 additions and 4 deletions

View File

@ -3,7 +3,7 @@ use std::path::Path;
use std::fs::File;
use std::time::Duration;
#[cfg(feature = "tls")] use hyper_rustls::WrappedStream;
#[cfg(feature = "tls")] use super::net_stream::HttpsStream;
use super::data_stream::DataStream;
use super::net_stream::NetStream;
@ -82,7 +82,7 @@ impl Data {
#[cfg(feature = "tls")]
fn concrete_stream(stream: &&mut NetworkStream) -> Option<NetStream> {
stream.downcast_ref::<WrappedStream>()
stream.downcast_ref::<HttpsStream>()
.map(|s| NetStream::Https(s.clone()))
.or_else(|| {
stream.downcast_ref::<HttpStream>()

View File

@ -2,18 +2,20 @@ use std::io::{self, Cursor};
use std::net::{SocketAddr, Shutdown};
use std::time::Duration;
#[cfg(feature = "tls")] use hyper_rustls::WrappedStream as RustlsStream;
#[cfg(feature = "tls")] use hyper_rustls::{WrappedStream, ServerSession};
use http::hyper::net::{HttpStream, NetworkStream};
use self::NetStream::*;
#[cfg(feature = "tls")] pub type HttpsStream = WrappedStream<ServerSession>;
// This is a representation of all of the possible network streams we might get.
// This really shouldn't be necessary, but, you know, Hyper.
#[derive(Clone)]
pub enum NetStream {
Http(HttpStream),
#[cfg(feature = "tls")]
Https(RustlsStream),
Https(HttpsStream),
Local(Cursor<Vec<u8>>)
}