@@ -174,6 +174,43 @@ fn timeout_blocking_request() {
174174 assert_eq ! ( err. url( ) . map( |u| u. as_str( ) ) , Some ( url. as_str( ) ) ) ;
175175}
176176
177+ #[ cfg( feature = "blocking" ) ]
178+ #[ test]
179+ fn blocking_request_timeout_body ( ) {
180+ let _ = env_logger:: try_init ( ) ;
181+
182+ let client = reqwest:: blocking:: Client :: builder ( )
183+ // this should be overridden
184+ . connect_timeout ( Duration :: from_millis ( 200 ) )
185+ // this should be overridden
186+ . timeout ( Duration :: from_millis ( 200 ) )
187+ . build ( )
188+ . unwrap ( ) ;
189+
190+ let server = server:: http ( move |_req| {
191+ async {
192+ // immediate response, but delayed body
193+ let body = hyper:: Body :: wrap_stream ( futures_util:: stream:: once ( async {
194+ tokio:: time:: sleep ( Duration :: from_secs ( 1 ) ) . await ;
195+ Ok :: < _ , std:: convert:: Infallible > ( "Hello" )
196+ } ) ) ;
197+
198+ http:: Response :: new ( body)
199+ }
200+ } ) ;
201+
202+ let url = format ! ( "http://{}/closes" , server. addr( ) ) ;
203+ let res = client
204+ . get ( & url)
205+ // longer than client timeout
206+ . timeout ( Duration :: from_secs ( 5 ) )
207+ . send ( )
208+ . expect ( "get response" ) ;
209+
210+ let text = res. text ( ) . unwrap ( ) ;
211+ assert_eq ! ( text, "Hello" ) ;
212+ }
213+
177214#[ cfg( feature = "blocking" ) ]
178215#[ test]
179216fn write_timeout_large_body ( ) {
0 commit comments