feat(ssl): redesign SSL usage
BREAKING CHANGE: Server::https was changed to allow any implementation of Ssl. Server in general was also changed. HttpConnector no longer uses SSL; using HttpsConnector instead.
This commit is contained in:
		| @@ -12,7 +12,7 @@ use Error; | ||||
| use header::{Headers, ContentLength, TransferEncoding}; | ||||
| use header::Encoding::Chunked; | ||||
| use method::{Method}; | ||||
| use net::{NetworkConnector, NetworkStream, ContextVerifier}; | ||||
| use net::{NetworkConnector, NetworkStream}; | ||||
| use status::StatusCode; | ||||
| use version::HttpVersion; | ||||
| use version::HttpVersion::{Http10, Http11}; | ||||
| @@ -264,11 +264,6 @@ impl Protocol for Http11Protocol { | ||||
|  | ||||
|         Ok(Box::new(Http11Message::with_stream(stream))) | ||||
|     } | ||||
|  | ||||
|     #[inline] | ||||
|     fn set_ssl_verifier(&mut self, verifier: ContextVerifier) { | ||||
|         self.connector.set_ssl_verifier(verifier); | ||||
|     } | ||||
| } | ||||
|  | ||||
| impl Http11Protocol { | ||||
| @@ -292,10 +287,6 @@ impl<C: NetworkConnector<Stream=S> + Send + Sync, S: NetworkStream + Send> Netwo | ||||
|         -> ::Result<Box<NetworkStream + Send>> { | ||||
|         Ok(try!(self.0.connect(host, port, scheme)).into()) | ||||
|     } | ||||
|     #[inline] | ||||
|     fn set_ssl_verifier(&mut self, verifier: ContextVerifier) { | ||||
|         self.0.set_ssl_verifier(verifier); | ||||
|     } | ||||
| } | ||||
|  | ||||
| struct Connector(Box<NetworkConnector<Stream=Box<NetworkStream + Send>> + Send + Sync>); | ||||
| @@ -307,10 +298,6 @@ impl NetworkConnector for Connector { | ||||
|         -> ::Result<Box<NetworkStream + Send>> { | ||||
|         Ok(try!(self.0.connect(host, port, scheme)).into()) | ||||
|     } | ||||
|     #[inline] | ||||
|     fn set_ssl_verifier(&mut self, verifier: ContextVerifier) { | ||||
|         self.0.set_ssl_verifier(verifier); | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -12,7 +12,7 @@ use http::{ | ||||
|     ResponseHead, | ||||
|     RawStatus, | ||||
| }; | ||||
| use net::{NetworkStream, NetworkConnector, ContextVerifier}; | ||||
| use net::{NetworkStream, NetworkConnector}; | ||||
| use net::{HttpConnector, HttpStream}; | ||||
| use url::Url; | ||||
| use header::Headers; | ||||
| @@ -133,11 +133,6 @@ impl<C, S> Protocol for Http2Protocol<C, S> where C: NetworkConnector<Stream=S> | ||||
|  | ||||
|         Ok(Box::new(Http2Message::with_client(client))) | ||||
|     } | ||||
|  | ||||
|     #[inline] | ||||
|     fn set_ssl_verifier(&mut self, verifier: ContextVerifier) { | ||||
|         self.connector.set_ssl_verifier(verifier) | ||||
|     } | ||||
| } | ||||
|  | ||||
| /// Represents an HTTP/2 request, described by a `RequestHead` and the body of the request. | ||||
| @@ -387,7 +382,7 @@ impl<S> HttpMessage for Http2Message<S> where S: CloneableStream { | ||||
| /// (which produces an `HttpStream` for the underlying transport layer). | ||||
| #[inline] | ||||
| pub fn new_protocol() -> Http2Protocol<HttpConnector, HttpStream> { | ||||
|     Http2Protocol::with_connector(HttpConnector(None)) | ||||
|     Http2Protocol::with_connector(HttpConnector) | ||||
| } | ||||
|  | ||||
| #[cfg(test)] | ||||
|   | ||||
| @@ -16,15 +16,12 @@ use url::Url; | ||||
| use method; | ||||
| use version; | ||||
| use traitobject; | ||||
| use net::ContextVerifier; | ||||
|  | ||||
| /// The trait provides an API for creating new `HttpMessage`s depending on the underlying HTTP | ||||
| /// protocol. | ||||
| pub trait Protocol { | ||||
|     /// Creates a fresh `HttpMessage` bound to the given host, based on the given protocol scheme. | ||||
|     fn new_message(&self, host: &str, port: u16, scheme: &str) -> ::Result<Box<HttpMessage>>; | ||||
|     /// Sets the SSL verifier that should be used when establishing TLS-protected connections. | ||||
|     fn set_ssl_verifier(&mut self, verifier: ContextVerifier); | ||||
| } | ||||
|  | ||||
| /// Describes a request. | ||||
| @@ -63,7 +60,9 @@ pub trait HttpMessage: Write + Read + Send + Any + Typeable + Debug { | ||||
|     /// After this, the `HttpMessage` instance can be used as an `io::Read` in order to read out | ||||
|     /// the response body. | ||||
|     fn get_incoming(&mut self) -> ::Result<ResponseHead>; | ||||
|  | ||||
|     /// Set the read timeout duration for this message. | ||||
|     #[cfg(feature = "timeouts")] | ||||
|     fn set_read_timeout(&self, dur: Option<Duration>) -> ::Result<()>; | ||||
|     /// Closes the underlying HTTP connection. | ||||
|     fn close_connection(&mut self) -> ::Result<()>; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user