File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -839,4 +839,30 @@ mod test {
839
839
840
840
Ok ( ( ) )
841
841
}
842
+
843
+ #[ async_std:: test]
844
+ async fn chain_skip_start ( ) -> crate :: Result < ( ) > {
845
+ for buf_len in 1 ..26 {
846
+ let mut body1 = Body :: from_reader ( Cursor :: new ( "1234 hello xyz" ) , Some ( 11 ) ) ;
847
+ let mut buf = vec ! [ 0 ; 5 ] ;
848
+ body1. read ( & mut buf) . await ?;
849
+ assert_eq ! ( buf, b"1234 " ) ;
850
+
851
+ let mut body2 = Body :: from_reader ( Cursor :: new ( "321 world abc" ) , Some ( 9 ) ) ;
852
+ let mut buf = vec ! [ 0 ; 4 ] ;
853
+ body2. read ( & mut buf) . await ?;
854
+ assert_eq ! ( buf, b"321 " ) ;
855
+
856
+ let mut body = body1. chain ( body2) ;
857
+ assert_eq ! ( body. len( ) , Some ( 11 ) ) ;
858
+ assert_eq ! ( body. mime( ) , & mime:: BYTE_STREAM ) ;
859
+ assert_eq ! (
860
+ read_with_buffers_of_size( & mut body, buf_len) . await ?,
861
+ "hello world"
862
+ ) ;
863
+ assert_eq ! ( body. bytes_read, 11 ) ;
864
+ }
865
+
866
+ Ok ( ( ) )
867
+ }
842
868
}
You can’t perform that action at this time.
0 commit comments