@@ -75,7 +75,9 @@ pub struct ClientBuilder {
7575 url : Uri ,
7676 headers : HeaderMap ,
7777 reconnect_opts : ReconnectOptions ,
78+ connect_timeout : Option < Duration > ,
7879 read_timeout : Option < Duration > ,
80+ write_timeout : Option < Duration > ,
7981 last_event_id : Option < String > ,
8082 method : String ,
8183 body : Option < String > ,
@@ -97,7 +99,9 @@ impl ClientBuilder {
9799 url,
98100 headers : header_map,
99101 reconnect_opts : ReconnectOptions :: default ( ) ,
102+ connect_timeout : None ,
100103 read_timeout : None ,
104+ write_timeout : None ,
101105 last_event_id : None ,
102106 method : String :: from ( "GET" ) ,
103107 max_redirects : None ,
@@ -144,12 +148,25 @@ impl ClientBuilder {
144148 self . header ( "Authorization" , & value)
145149 }
146150
151+ /// Set a connect timeout for the underlying connection. There is no connect timeout by
152+ /// default.
153+ pub fn connect_timeout ( mut self , connect_timeout : Duration ) -> ClientBuilder {
154+ self . connect_timeout = Some ( connect_timeout) ;
155+ self
156+ }
157+
147158 /// Set a read timeout for the underlying connection. There is no read timeout by default.
148159 pub fn read_timeout ( mut self , read_timeout : Duration ) -> ClientBuilder {
149160 self . read_timeout = Some ( read_timeout) ;
150161 self
151162 }
152163
164+ /// Set a write timeout for the underlying connection. There is no write timeout by default.
165+ pub fn write_timeout ( mut self , write_timeout : Duration ) -> ClientBuilder {
166+ self . write_timeout = Some ( write_timeout) ;
167+ self
168+ }
169+
153170 /// Configure the client's reconnect behaviour according to the supplied
154171 /// [`ReconnectOptions`].
155172 ///
@@ -176,7 +193,9 @@ impl ClientBuilder {
176193 C :: Error : Into < BoxError > ,
177194 {
178195 let mut connector = TimeoutConnector :: new ( conn) ;
196+ connector. set_connect_timeout ( self . connect_timeout ) ;
179197 connector. set_read_timeout ( self . read_timeout ) ;
198+ connector. set_write_timeout ( self . write_timeout ) ;
180199
181200 let client = hyper:: Client :: builder ( ) . build :: < _ , hyper:: Body > ( connector) ;
182201
0 commit comments