@@ -410,7 +410,9 @@ impl<F> NetworkConnector for F where F: Fn(&str, u16, &str) -> io::Result<TcpStr
410
410
}
411
411
}
412
412
413
- /// An abstraction to allow any SSL implementation to be used with HttpsStreams.
413
+ /// Deprecated
414
+ ///
415
+ /// Use `SslClient` and `SslServer` instead.
414
416
pub trait Ssl {
415
417
/// The protected stream.
416
418
type Stream : NetworkStream + Send + Clone ;
@@ -420,6 +422,38 @@ pub trait Ssl {
420
422
fn wrap_server ( & self , stream : HttpStream ) -> :: Result < Self :: Stream > ;
421
423
}
422
424
425
+ /// An abstraction to allow any SSL implementation to be used with client-side HttpsStreams.
426
+ pub trait SslClient {
427
+ /// The protected stream.
428
+ type Stream : NetworkStream + Send + Clone ;
429
+ /// Wrap a client stream with SSL.
430
+ fn wrap_client ( & self , stream : HttpStream , host : & str ) -> :: Result < Self :: Stream > ;
431
+ }
432
+
433
+ /// An abstraction to allow any SSL implementation to be used with server-side HttpsStreams.
434
+ pub trait SslServer {
435
+ /// The protected stream.
436
+ type Stream : NetworkStream + Send + Clone ;
437
+ /// Wrap a server stream with SSL.
438
+ fn wrap_server ( & self , stream : HttpStream ) -> :: Result < Self :: Stream > ;
439
+ }
440
+
441
+ impl < S : Ssl > SslClient for S {
442
+ type Stream = <S as Ssl >:: Stream ;
443
+
444
+ fn wrap_client ( & self , stream : HttpStream , host : & str ) -> :: Result < Self :: Stream > {
445
+ Ssl :: wrap_client ( self , stream, host)
446
+ }
447
+ }
448
+
449
+ impl < S : Ssl > SslServer for S {
450
+ type Stream = <S as Ssl >:: Stream ;
451
+
452
+ fn wrap_server ( & self , stream : HttpStream ) -> :: Result < Self :: Stream > {
453
+ Ssl :: wrap_server ( self , stream)
454
+ }
455
+ }
456
+
423
457
/// A stream over the HTTP protocol, possibly protected by SSL.
424
458
#[ derive( Debug , Clone ) ]
425
459
pub enum HttpsStream < S : NetworkStream > {
@@ -493,7 +527,7 @@ impl<S: NetworkStream> NetworkStream for HttpsStream<S> {
493
527
494
528
/// A Http Listener over SSL.
495
529
#[ derive( Clone ) ]
496
- pub struct HttpsListener < S : Ssl > {
530
+ pub struct HttpsListener < S : SslServer > {
497
531
listener : HttpListener ,
498
532
ssl : S ,
499
533
}
@@ -516,7 +550,7 @@ impl<S: Ssl> HttpsListener<S> {
516
550
}
517
551
}
518
552
519
- impl < S : Ssl + Clone > NetworkListener for HttpsListener < S > {
553
+ impl < S : SslServer + Clone > NetworkListener for HttpsListener < S > {
520
554
type Stream = S :: Stream ;
521
555
522
556
#[ inline]
@@ -532,18 +566,18 @@ impl<S: Ssl + Clone> NetworkListener for HttpsListener<S> {
532
566
533
567
/// A connector that can protect HTTP streams using SSL.
534
568
#[ derive( Debug , Default ) ]
535
- pub struct HttpsConnector < S : Ssl > {
569
+ pub struct HttpsConnector < S : SslClient > {
536
570
ssl : S
537
571
}
538
572
539
- impl < S : Ssl > HttpsConnector < S > {
573
+ impl < S : SslClient > HttpsConnector < S > {
540
574
/// Create a new connector using the provided SSL implementation.
541
575
pub fn new ( s : S ) -> HttpsConnector < S > {
542
576
HttpsConnector { ssl : s }
543
577
}
544
578
}
545
579
546
- impl < S : Ssl > NetworkConnector for HttpsConnector < S > {
580
+ impl < S : SslClient > NetworkConnector for HttpsConnector < S > {
547
581
type Stream = HttpsStream < S :: Stream > ;
548
582
549
583
fn connect ( & self , host : & str , port : u16 , scheme : & str ) -> :: Result < Self :: Stream > {
0 commit comments