@@ -27,9 +27,14 @@ impl HttpsConnector {
27
27
let mut http = HttpConnector :: new ( threads, handle) ;
28
28
http. enforce_http ( false ) ;
29
29
let mut config = ClientConfig :: new ( ) ;
30
- config. root_store . add_server_trust_anchors ( & webpki_roots:: TLS_SERVER_ROOTS ) ;
30
+ config
31
+ . root_store
32
+ . add_server_trust_anchors ( & webpki_roots:: TLS_SERVER_ROOTS ) ;
31
33
config. ct_logs = Some ( & ct_logs:: LOGS ) ;
32
- HttpsConnector { http : http, tls_config : Arc :: new ( config) }
34
+ HttpsConnector {
35
+ http : http,
36
+ tls_config : Arc :: new ( config) ,
37
+ }
33
38
}
34
39
}
35
40
@@ -59,45 +64,39 @@ impl Service for HttpsConnector {
59
64
let host: DNSName = match uri. host ( ) {
60
65
Some ( host) => match DNSNameRef :: try_from_ascii_str ( host) {
61
66
Ok ( host) => host. into ( ) ,
62
- Err ( err) => return HttpsConnecting (
63
- Box :: new (
64
- :: futures:: future:: err (
65
- io:: Error :: new (
66
- io:: ErrorKind :: InvalidInput ,
67
- format ! ( "invalid url: {:?}" , err) ,
68
- )
69
- )
70
- )
71
- ) ,
67
+ Err ( err) => {
68
+ return HttpsConnecting ( Box :: new ( :: futures:: future:: err ( io:: Error :: new (
69
+ io:: ErrorKind :: InvalidInput ,
70
+ format ! ( "invalid url: {:?}" , err) ,
71
+ ) ) ) )
72
+ }
72
73
} ,
73
- None => return HttpsConnecting (
74
- Box :: new (
75
- :: futures:: future:: err (
76
- io:: Error :: new (
77
- io:: ErrorKind :: InvalidInput ,
78
- "invalid url, missing host"
79
- )
80
- )
81
- )
82
- ) ,
74
+ None => {
75
+ return HttpsConnecting ( Box :: new ( :: futures:: future:: err ( io:: Error :: new (
76
+ io:: ErrorKind :: InvalidInput ,
77
+ "invalid url, missing host" ,
78
+ ) ) ) )
79
+ }
83
80
} ;
84
81
let connecting = self . http . call ( uri) ;
85
82
86
83
HttpsConnecting ( if is_https {
87
84
let tls = self . tls_config . clone ( ) ;
88
- Box :: new ( connecting. and_then ( move |tcp| {
89
- tls
90
- . connect_async ( host. as_ref ( ) , tcp)
91
- . map_err ( |e| io:: Error :: new ( io:: ErrorKind :: Other , e) )
92
- } ) . map ( |tls| MaybeHttpsStream :: Https ( tls) )
93
- . map_err ( |e| io:: Error :: new ( io:: ErrorKind :: Other , e) ) )
85
+ Box :: new (
86
+ connecting
87
+ . and_then ( move |tcp| {
88
+ tls. connect_async ( host. as_ref ( ) , tcp)
89
+ . map_err ( |e| io:: Error :: new ( io:: ErrorKind :: Other , e) )
90
+ } )
91
+ . map ( |tls| MaybeHttpsStream :: Https ( tls) )
92
+ . map_err ( |e| io:: Error :: new ( io:: ErrorKind :: Other , e) ) ,
93
+ )
94
94
} else {
95
95
Box :: new ( connecting. map ( |tcp| MaybeHttpsStream :: Http ( tcp) ) )
96
96
} )
97
97
}
98
98
}
99
99
100
-
101
100
pub struct HttpsConnecting ( Box < Future < Item = MaybeHttpsStream , Error = io:: Error > > ) ;
102
101
103
102
impl Future for HttpsConnecting {
0 commit comments