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::*;
1818pub struct OutboundHttp {
1919 /// List of hosts guest modules are allowed to make requests to.
2020 pub allowed_hosts : AllowedHttpHosts ,
21+ client : Option < Client > ,
2122}
2223
2324impl OutboundHttp {
24- pub fn new ( allowed_hosts : AllowedHttpHosts ) -> Self {
25- Self { allowed_hosts }
26- }
27-
2825 /// Check if guest module is allowed to send request to URL, based on the list of
2926 /// allowed hosts defined by the runtime. If the list of allowed hosts contains
3027 /// `insecure:allow-all`, then all hosts are allowed.
@@ -52,7 +49,10 @@ impl wasi_outbound_http::WasiOutboundHttp for OutboundHttp {
5249 tracing:: log:: warn!( "HTTP params field is deprecated" ) ;
5350 }
5451
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+
5656 let resp = client
5757 . request ( method, url)
5858 . headers ( headers)
You can’t perform that action at this time.
0 commit comments