File tree Expand file tree Collapse file tree
uefi-test-runner/src/proto/network Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,14 +74,11 @@ fn fetch_http(handle: Handle, url: &str) -> Option<Vec<u8>> {
7474 break ;
7575 }
7676
77- let res = http. response_more ( ) ;
77+ let res = http. response_more ( & mut data ) ;
7878 if let Err ( e) = res {
7979 error ! ( "read response: {e}" ) ;
8080 return None ;
8181 }
82-
83- let mut buf = res. unwrap ( ) ;
84- data. append ( & mut buf) ;
8582 }
8683
8784 Some ( data)
Original file line number Diff line number Diff line change @@ -347,12 +347,13 @@ impl HttpHelper {
347347 Ok ( rsp)
348348 }
349349
350- /// Receive more body data.
351- pub fn response_more ( & mut self ) -> uefi:: Result < Vec < u8 > > {
352- let mut body = vec ! [ 0 ; 16 * 1024 ] ;
350+ /// Try to receive more of the HTTP response and append any new data to the
351+ /// provided `body` vector.
352+ pub fn response_more < ' a > ( & mut self , body : & ' a mut Vec < u8 > ) -> uefi:: Result < & ' a [ u8 ] > {
353+ let mut body_recv_buffer = vec ! [ 0 ; 16 * 1024 ] ;
353354 let mut rx_msg = HttpMessage {
354- body_length : body . len ( ) ,
355- body : body . as_mut_ptr ( ) . cast :: < c_void > ( ) ,
355+ body_length : body_recv_buffer . len ( ) ,
356+ body : body_recv_buffer . as_mut_ptr ( ) . cast :: < c_void > ( ) ,
356357 ..Default :: default ( )
357358 } ;
358359
@@ -378,9 +379,16 @@ impl HttpHelper {
378379 return Err ( rx_token. status . into ( ) ) ;
379380 } ;
380381
381- debug ! ( "http: body: {}/{}" , rx_msg. body_length, body. len( ) ) ;
382+ debug ! (
383+ "http: body: {}/{}" ,
384+ rx_msg. body_length,
385+ body_recv_buffer. len( )
386+ ) ;
382387
383- Ok ( body[ 0 ..rx_msg. body_length ] . to_vec ( ) )
388+ let new_data = & body_recv_buffer[ 0 ..rx_msg. body_length ] ;
389+ body. extend ( new_data) ;
390+ let new_data_slice = & body[ body. len ( ) - new_data. len ( ) ..] ;
391+ Ok ( new_data_slice)
384392 }
385393}
386394
You can’t perform that action at this time.
0 commit comments