File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -8,15 +8,20 @@ struct Data {
8
8
}
9
9
10
10
fn main ( ) {
11
- let buffer = [ 0 ; 5000 ] ;
11
+ // Make sure the final body is larger than 1024*1024, but we cannot allocate
12
+ // so much memory directly in the wasm program, so we use the `repeat`
13
+ // method to increase the body size.
14
+ const LEN : usize = 1024 ;
15
+ const REPEAT : usize = 1025 ;
16
+ let buffer = [ 0 ; LEN ] ;
12
17
let resp = Client :: new ( )
13
18
. post ( "https://httpbin.org/post" )
14
- . body ( buffer)
19
+ . body ( buffer. repeat ( REPEAT ) )
15
20
. connect_timeout ( Duration :: from_secs ( 5 ) )
16
21
. send ( )
17
22
. unwrap ( ) ;
18
23
assert_eq ! ( resp. status_code( ) , 200 ) ;
19
24
20
25
let data = resp. json :: < Data > ( ) . unwrap ( ) ;
21
- assert_eq ! ( data. data. len( ) , 5000 ) ;
26
+ assert_eq ! ( data. data. len( ) , LEN * REPEAT ) ;
22
27
}
Original file line number Diff line number Diff line change @@ -232,19 +232,20 @@ impl Request {
232
232
. map_err ( |( ) | anyhow ! ( "failed to set path_with_query" ) ) ?;
233
233
}
234
234
235
+ let outgoing_body = req
236
+ . body ( )
237
+ . map_err ( |_| anyhow ! ( "outgoing request write failed" ) ) ?;
238
+
235
239
let options = RequestOptions :: new ( ) ;
236
240
options
237
241
. set_connect_timeout ( self . connect_timeout )
238
242
. map_err ( |( ) | anyhow ! ( "failed to set connect_timeout" ) ) ?;
243
+ let future_response = outgoing_handler:: handle ( req, Some ( options) ) ?;
239
244
240
- let outgoing_body = req
241
- . body ( )
242
- . map_err ( |_| anyhow ! ( "outgoing request write failed" ) ) ?;
243
245
let body = self . body . bytes ( ) ?;
244
246
write_to_outgoing_body ( & outgoing_body, body. as_slice ( ) ) ?;
245
247
OutgoingBody :: finish ( outgoing_body, None ) ?;
246
248
247
- let future_response = outgoing_handler:: handle ( req, Some ( options) ) ?;
248
249
let incoming_response = match future_response. get ( ) {
249
250
Some ( result) => result. map_err ( |( ) | anyhow ! ( "response already taken" ) ) ?,
250
251
None => {
You can’t perform that action at this time.
0 commit comments