@@ -115,6 +115,12 @@ pub enum Error {
115
115
pub struct Builder {
116
116
/// Number of DNS worker threads
117
117
dns_workers : usize ,
118
+
119
+ /// Request timeout
120
+ timeout : Duration ,
121
+
122
+ /// Send null body
123
+ send_null_body : bool ,
118
124
}
119
125
120
126
impl fmt:: Display for Error {
@@ -154,7 +160,11 @@ impl error::Error for Error {
154
160
155
161
impl Default for Builder {
156
162
fn default ( ) -> Self {
157
- Self { dns_workers : 4 }
163
+ Self {
164
+ dns_workers : 4 ,
165
+ timeout : Duration :: from_secs ( std:: u64:: MAX ) ,
166
+ send_null_body : true ,
167
+ }
158
168
}
159
169
}
160
170
@@ -168,6 +178,24 @@ impl Builder {
168
178
self
169
179
}
170
180
181
+ /// Set request timeout
182
+ ///
183
+ /// Default is no timeout
184
+ #[ inline]
185
+ pub fn timeout ( & mut self , timeout : Duration ) -> & mut Self {
186
+ self . timeout = timeout;
187
+ self
188
+ }
189
+
190
+ /// Send null body in POST/PUT
191
+ ///
192
+ /// Default is yes
193
+ #[ inline]
194
+ pub fn send_null_body ( & mut self , value : bool ) -> & mut Self {
195
+ self . send_null_body = value;
196
+ self
197
+ }
198
+
171
199
/// Create `RestClient` with the configuration in this builder
172
200
pub fn build ( & self , url : & str ) -> Result < RestClient , Error > {
173
201
RestClient :: with_builder ( url, self )
@@ -209,8 +237,8 @@ impl RestClient {
209
237
baseurl,
210
238
auth : None ,
211
239
headers : HeaderMap :: new ( ) ,
212
- timeout : Duration :: from_secs ( std :: u64 :: MAX ) ,
213
- send_null_body : true ,
240
+ timeout : builder . timeout ,
241
+ send_null_body : builder . send_null_body ,
214
242
} )
215
243
}
216
244
0 commit comments