File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -309,6 +309,16 @@ where
309309 . map ( |opt_chunk| opt_chunk. map_err ( crate :: error:: body) ) ,
310310 )
311311 }
312+
313+ #[ inline]
314+ fn size_hint ( & self ) -> http_body:: SizeHint {
315+ self . inner . size_hint ( )
316+ }
317+
318+ #[ inline]
319+ fn is_end_stream ( & self ) -> bool {
320+ self . inner . is_end_stream ( )
321+ }
312322}
313323
314324pub ( crate ) type ResponseBody =
Original file line number Diff line number Diff line change @@ -303,3 +303,23 @@ fn write_timeout_large_body() {
303303 assert ! ( err. is_timeout( ) ) ;
304304 assert_eq ! ( err. url( ) . map( |u| u. as_str( ) ) , Some ( url. as_str( ) ) ) ;
305305}
306+
307+ #[ tokio:: test]
308+ async fn response_body_timeout_forwards_size_hint ( ) {
309+ let _ = env_logger:: try_init ( ) ;
310+
311+ let server = server:: http ( move |_req| async { http:: Response :: new ( b"hello" . to_vec ( ) . into ( ) ) } ) ;
312+
313+ let client = reqwest:: Client :: new ( ) ;
314+
315+ let url = format ! ( "http://{}/slow" , server. addr( ) ) ;
316+
317+ let res = client
318+ . get ( & url)
319+ . timeout ( Duration :: from_secs ( 1 ) )
320+ . send ( )
321+ . await
322+ . expect ( "response" ) ;
323+
324+ assert_eq ! ( res. content_length( ) , Some ( 5 ) ) ;
325+ }
You can’t perform that action at this time.
0 commit comments