1313// limitations under the License.
1414
1515use proxy_wasm:: callout:: http:: HttpClient ;
16- use proxy_wasm:: hostcalls;
1716use proxy_wasm:: callout:: promise:: Promise ;
17+ use proxy_wasm:: hostcalls;
1818use proxy_wasm:: traits:: * ;
1919use proxy_wasm:: types:: * ;
2020use std:: time:: Duration ;
@@ -32,40 +32,40 @@ struct HttpParallelCall {
3232impl HttpContext for HttpParallelCall {
3333 fn on_http_request_headers ( & mut self , _: usize , _: bool ) -> Action {
3434 // "Hello, "
35- let promise1 = self . client . dispatch (
36- "httpbin" ,
37- vec ! [
38- ( ":method" , "GET" ) ,
39- ( ":path" , "/base64/SGVsbG8sIA==" ) ,
40- ( ":authority" , "httpbin.org" ) ,
41- ] ,
42- None ,
43- vec ! [ ] ,
44- Duration :: from_secs ( 1 ) ,
45- ) ;
35+ let promise1 = self
36+ . client
37+ . dispatch (
38+ "httpbin" ,
39+ vec ! [
40+ ( ":method" , "GET" ) ,
41+ ( ":path" , "/base64/SGVsbG8sIA==" ) ,
42+ ( ":authority" , "httpbin.org" ) ,
43+ ] ,
44+ None ,
45+ vec ! [ ] ,
46+ Duration :: from_secs ( 1 ) ,
47+ )
48+ . then ( |( _, _, body_size, _) | get_http_call_response_body_string ( 0 , body_size) )
49+ . then ( |body| body. unwrap_or_default ( ) ) ;
4650
4751 // "World!"
48- let promise2 = self . client . dispatch (
49- "httpbin" ,
50- vec ! [
51- ( ":method" , "GET" ) ,
52- ( ":path" , "/base64/V29ybGQh" ) ,
53- ( ":authority" , "httpbin.org" ) ,
54- ] ,
55- None ,
56- vec ! [ ] ,
57- Duration :: from_secs ( 1 ) ,
58- ) ;
52+ let promise2 = self
53+ . client
54+ . dispatch (
55+ "httpbin" ,
56+ vec ! [
57+ ( ":method" , "GET" ) ,
58+ ( ":path" , "/base64/V29ybGQh" ) ,
59+ ( ":authority" , "httpbin.org" ) ,
60+ ] ,
61+ None ,
62+ vec ! [ ] ,
63+ Duration :: from_secs ( 1 ) ,
64+ )
65+ . then ( |( _, _, body_size, _) | get_http_call_response_body_string ( 0 , body_size) )
66+ . then ( |body| body. unwrap_or_default ( ) ) ;
5967
60- Promise :: all_of ( vec ! [
61- promise1
62- . then( |( _, _, body_size, _) | get_http_call_response_body_string( 0 , body_size) )
63- . then( |body| body. unwrap_or_default( ) ) ,
64- promise2
65- . then( |( _, _, body_size, _) | get_http_call_response_body_string( 0 , body_size) )
66- . then( |body| body. unwrap_or_default( ) ) ,
67- ] )
68- . then ( |results| {
68+ Promise :: all_of ( vec ! [ promise1, promise2] ) . then ( |results| {
6969 send_http_response (
7070 200 ,
7171 vec ! [ ] ,
0 commit comments