File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -18,13 +18,10 @@ use wasi_outbound_http::*;
18
18
pub struct OutboundHttp {
19
19
/// List of hosts guest modules are allowed to make requests to.
20
20
pub allowed_hosts : AllowedHttpHosts ,
21
+ client : Option < Client > ,
21
22
}
22
23
23
24
impl OutboundHttp {
24
- pub fn new ( allowed_hosts : AllowedHttpHosts ) -> Self {
25
- Self { allowed_hosts }
26
- }
27
-
28
25
/// Check if guest module is allowed to send request to URL, based on the list of
29
26
/// allowed hosts defined by the runtime. If the list of allowed hosts contains
30
27
/// `insecure:allow-all`, then all hosts are allowed.
@@ -52,7 +49,10 @@ impl wasi_outbound_http::WasiOutboundHttp for OutboundHttp {
52
49
tracing:: log:: warn!( "HTTP params field is deprecated" ) ;
53
50
}
54
51
55
- let client = Client :: builder ( ) . build ( ) . unwrap ( ) ;
52
+ // Allow reuse of Client's internal connection pool for multiple requests
53
+ // in a single component execution
54
+ let client = self . client . get_or_insert_with ( Default :: default) ;
55
+
56
56
let resp = client
57
57
. request ( method, url)
58
58
. headers ( headers)
You can’t perform that action at this time.
0 commit comments